Android日常佈局一
阿新 • • 發佈:2019-02-11
ScrollView
- 只能包含一個控制元件
FrameLayout
- 越遲新增的控制元件處於越上層
layout
- 命名必須小寫
常用屬性
descendantFocusability
- beforeDescendants:viewgroup會優先其子類控制元件而獲取到焦點
- afterDescendants:viewgroup只有當其子類控制元件不需要獲取焦點時才獲取焦點
- blocksDescendants:viewgroup會覆蓋子類控制元件而直接獲得焦點
ellipsize
- 設定省略號位置
weight
- weight在fill_parent情況下的權重計算,計算剩餘空間的權重,然後求和
transcriptMode
- Android控制元件(支援ScrollBar)自動滑動到最底部(“alwaysScroll”)
ListView
- 自動顯示隱藏進度條
android:fadeScrollbars="true"
- 顯示列表最後一條
stackFromBottom="true"
- 去除滑動陰影
android:fadingEdge="none"
android: overScrollMode="never" - 選擇顏色顯示位置
drawSelectorOnTop
- 背景顏色為圖片時,設定快取為透明
CacheColorHint="#00000000"
EditText
InputType
- number 接受整數輸入
- numberSigned 接受有符號整數輸入
- numberDecimal 接受整數和小數的輸入
digits
- 指定固定數字
android:digits="012345"
當InputType屬性為number時,lines失效
預設外觀
android:textAppearance="?android:attr/textAppearanceSmall"
imeOptions
屬性 | 標誌位 |
---|---|
actionUnspecified | EditorInfo.IME_ACTION_UNSPECIFIED. |
actionNone | EditorInfo.IME_ACTION_NONE |
actionGo 去往 | EditorInfo.IME_ACTION_GO |
actionSearch 搜尋 | EditorInfo.IME_ACTION_SEARCH |
actionSend 傳送 | EditorInfo.IME_ACTION_SEND |
actionNext 下一個 | EditorInfo.IME_ACTION_NEXT |
actionDone 完成 | EditorInfo.IME_ACTION_DONE |
style
- 引導介面不顯示title
<item name="android:windowNoTitle">true</item>
- 對話方塊style
<style name="CustomDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>//Dialog的windowFrame框為無
<item name="android:windowIsFloating">true</item>//是否浮現在activity之上
<item name="android:windowContentOverlay">@null</item>//是否允許背景灰暗
<item name="android:windowAnimationStyle">
@android:style/Animation.Dialog</item>//對話方塊的進入和退出動畫
//可控制軟鍵盤的顯示與否
<item name="android:windowSoftInputMode">
stateUnspecified|adjustPan</item>
</style>
imageView
- 按比例放大縮小圖片
android: scaleType="fitXY"