How do I change the color of the separation line in the list view of Android?

Asked 1 years ago, Updated 1 years ago, 102 views

How do I change the color of the separation line in the list view of Android? Please teach me.

android android-listview

2022-09-22 22:30

1 Answers

In the xml file, you can change the color of the divider by giving the value of the desired color to android:divider. android:divider="#FF0000"Write it like this. You can also change the color of the divider and reduce the thickness of the divider with android:dividerHeight.

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

  <ListView 
    android:id="@+id/android:list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:divider="#FFCC00"
    android:dividerHeight="4px"/>

</LinearLayout>


2022-09-22 22:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.