Android ListView常見屬性問題

來源:互聯網
上載者:User

標籤:android

Question 1:

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

解決辦法:

     xml中:

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

    代碼中:

       setScrollingCacheEnabled(false)  或者 setCacheColorHint(0)  或者setCacheColorHint(Color.TRANSPARENT);


Question 2:

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

解決辦法:

  xml中:

       android:fadingEdge="none"  

 代碼中:

       setFadingEdgeLength(0);


Question 3:

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

解決辦法:

  xml中:

           android:divider="@drawable/list_driver

  java中:

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


Question 4:

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

   解決辦法:

     xml中:

               listSelector="@android:color/transparent

    java中:

            ListView.setSelector(drawable);


本文出自 “心向菩提” 部落格,請務必保留此出處http://zhongkun.blog.51cto.com/1057583/1407969

聯繫我們

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