How to change color of Android ListView separator line?

前端 未结 9 1632
时光取名叫无心
时光取名叫无心 2020-11-28 00:08

I want to change color of ListView separator line. Any help would be appreciated.

9条回答
  •  悲哀的现实
    2020-11-28 00:57

    There are two ways to doing the same:

    1. You may set the value of android:divider="#FFCCFF" in layout xml file. With this you also have to specify height of divider like this android:dividerHeight="5px".

      
      
        
      
      
      
    2. You may also do this by programmatically...

      ListView listView = getListView();
      ColorDrawable myColor = new ColorDrawable(
          this.getResources().getColor(R.color.myColor)
      );
      listView.setDivider(myColor);
      listView.setDividerHeight();
      

提交回复
热议问题