我有一个ListView
自定义项目布局和自定义背景。问题是在我将背景可绘制对象从 切换到android:padding
后,值似乎被忽略了。<shape>
<layer-list>
布局/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>
可绘制/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>
以上按预期工作。drawable/list_item_background.xml
当我更改为时,填充消失
<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>
我错过了什么?