Change separator color in LinearLayout

Can I learn how to change the color of a separator in LinearLayout ?

 <LinearLayout android:layout_width="match_parent" android:layout_height="48dp" android:orientation="horizontal" android:divider="?android:attr/dividerVertical" android:dividerPadding="12dip" android:showDividers="middle" android:background="#ff2d2d2d" > ... </LinearLayout> 

Do I need to manually copy 9 patch images from the Android SDK to my project and define my own attribute for its link?

+8
android android-linearlayout nine-patch
source share
3 answers

It looks like the android:divider attribute is not accepting a color value. So you need to create a separate delimiter for it to work:

divider.xml

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <size android:width="1dip" /> <solid android:color="#f00" /> </shape> 

layout.xml

 <LinearLayout android:layout_width="match_parent" android:layout_height="48dp" android:orientation="horizontal" android:divider="@drawable/divider" android:dividerPadding="12dip" android:showDividers="middle" android:background="#ff2d2d2d" > 

Also note that android:divider is only available in Android 3.0 or later, and it does not work in previous versions of Android.

+22
source share

This is how i did it

  <ImageView android:id="@+id/imgVwmarkupborder" android:layout_width="280dp" android:layout_height="2dp" android:src="@android:color/white" /> 
-2
source share
 <View android:layout_width="fill_parent" android:layout_height="1dp" android:background="@android:color/white"/> 

In my method, I use this ...

-3
source share

All Articles