標籤:android 介面 ui app
這周在公司App即將發布,根據UI的要求,再次對介面進行UI互動的調整。總結了一下小知識細節。
一、控制項擷取焦點
mText.setText("gfgss");mText.setFocusable(true);
xml裡面輸入框設定預設擷取焦點 <requestFocus />
<AutoCompleteTextView android:layout_width="0dp" android:layout_height="match_parent"> <requestFocus /> </AutoCompleteTextView>
二、怎樣把游標放在EditText中文本的末尾處?
mText.setSelection(mText.getText().length());
三、activity設定IME的問題,如有涉及懸浮的布局遮住輸入框用adjustPan
啟動時activity不彈出IMEstateHidden,在activity那裡配置。
android:windowSoftInputMode="stateHidden|adjustPan"
四、layout的分割線設定,或者listview的分割線
android:divider="@drawable/shape_divider"android:showDividers="beginning|middle|end"
五、去掉listview滾動顯示
android:scrollbars="none"
六、去掉listview的分割線
android:divider="@null"
七、去除預設的點擊選中時的顏色
(1)設定列表layout的backgroudcolor屬性就OK了。
(2)
android:focusable="false"android:focusableInTouchMode="false"android:cacheColorHint="#00000000"android:listSelector="#00000000"
八、替換listview 預設的點擊選中時的顏色
設定listivew的listSelector屬性就可以了。
九、智能的填充剩餘的螢幕
有時下面這兩條語句比android:layout_width="match_parent"這個好用。更加智能的填充剩餘的螢幕
android:layout_height="0dp"android:layout_weight="1"
十、使用ScrollView屬性fillViewport解決android布局不能撐滿全屏的問題
當ScrollView裡的元素想填滿ScrollView時,使用"fill_parent"是不管用的,必需為ScrollView設定:android:fillViewport="true"。
當ScrollView沒有fillVeewport=“true”時, 裡面的元素(比如LinearLayout)會按照wrap_content來計算(不論它是否設了"fill_parent"),而如果LinearLayout的元素設定了fill_parent,那麼也是不管用的,因為LinearLayout依賴裡面的元素,而裡面的元素又依賴LinearLayout,這樣自相矛盾.所以裡面元素設定了fill_parent,也會當做wrap_content來計算。
十一、 點擊對話方塊以外的部分,結束activity
public boolean onTouchEvent(MotionEvent event) {if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {finish();return true;}return super.onTouchEvent(event);}
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
Android UI細節知識點一(edittext、listview、填充螢幕等)