listView常用屬性設定

來源:互聯網
上載者:User

  轉 http://blog.csdn.net/tmj2014/article/details/7758787

  問題1:

listview在拖動的時候背景圖片消失變成黑色背景。等到拖動完畢我們自己的背景圖片才顯示出來。

解決辦法:

xml中: android:scrollingCache="false"  或者 android:cacheColorHint="#00000000"

代碼中: setScrollingCacheEnabled(false)  或者 setCacheColorHint(0)  或者setCacheColorHint(Color.TRANSPARENT);

 

問題2:

listview的上邊和下邊有黑色的陰影。

解決辦法:

xml中: android:fadingEdge="none"  

代碼中:setFadingEdgeLength(0);

 

問題3:

lsitview的每一項之間需要設定一個圖片做為間隔。

解決辦法:

xml中 :android:divider="@drawable/list_driver

java中:Drawable dr = this.getResources().getDrawable(R.colo.listviewdividerClour);
              ListView.setDivider(dr);

 

問題4:

預設會顯示選中的item為橙黃底色,有時候我們需要去掉這種效果:

解決辦法:

xml中:listSelector="@android:color/transparent

衍生:

ListView選中時預設是黃色,很多時候會和我們軟體的配色不符合,那麼需要修改預設的ListView配色,

java中:

    1. Drawable drawable=getResources().getDrawable(R.drawable.touch_feedback);  
    2. ListView.setSelector(drawable); 

xml中:

listSelector="@android:color/blue

同理運用到 GridView中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.