background disables android:padding setting -



<layer-list> background disables android:padding setting -

i have listview custom items layout , custom background. problem android:padding value seems ignored after switched background drawable <shape> <layer-list>.

layout/list_item.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_list_item_bill" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="12dp"> . . . </linearlayout>

drawable/list_item_background.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/white" /> <corners android:radius="@dimen/corner_radius" /> <stroke android:width="1dp" android:color="@color/blue" /> </shape>

the above works expected. padding disappears when alter drawable/list_item_background.xml to

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <solid android:color="@color/white"/> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="@color/white" /> <corners android:radius="@dimen/corner_radius" /> <stroke android:width="1dp" android:color="@color/blue" /> </shape> </item> </layer-list>

what missing?

wrapping <layer-list> in <selector> has solved issue:

<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <layer-list> <item> <shape> <solid android:color="@color/white"/> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="@color/white" /> <corners android:radius="@dimen/corner_radius" /> <stroke android:width="1dp" android:color="@color/blue" /> </shape> </item> </layer-list> </item> </selector>

android layer-list

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -