Android UI細節知識點一(edittext、listview、填充螢幕等)

來源:互聯網
上載者:User

標籤: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、填充螢幕等)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.