Open top menu


Change list divider color and Hight:

In this tutorial we will explain how to how to set listview  divider color programmatically and you have to change update in xml class.below explain-

android:divider="#95a5ff"/>

And you have to set the divider hight in xml class  .

android:dividerHeight="8dip”

<ListView
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
         android:dividerHeight="8dip”
         android:divider="#95a5ff" />

And you want to change listview divider color programtically onclick listview position.

         listView.setAdapter(adapter);
         listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
           public void onItemClick(AdapterView<?> parent, View view,
                                  int position, long id) {
           listView.setDivider(new ColorDrawable(Color.parseColor("#FF4A4D93")));

           listView.setDividerHeight(2);
                      
                     }

              });
Tagged

0 comments