<layer-list
xmlns:android="http://schemas.android.com/apk/res/android"
>
<!--width here doesn't work-->
<item
android:gravity="left"
android:width="10dp"
>
<shape
android:shape="rectangle"
>
<stroke
android:width="1dp"
android:color="@color/black"
/>
<!--<gradient-->
<!--android:startColor="#00dddddd"-->
<!--android:endColor="#40404040"-->
<!--android:angle="0"-->
<!--/>-->
</shape>
</item>
<!--width here doesn't work-->
<item
android:width="10dp"
android:gravity="right"
>
<shape
android:shape="rectangle"
>
<stroke
android:width="1dp"
android:color="@color/black"
/>
<!--<gradient-->
<!--android:startColor="#00dddddd"-->
<!--android:endColor="#40404040"-->
<!--android:angle="180"-->
<!--/>-->
</shape>
</item>
Here is the example.
It works in Lollipop or higher, but it doesn't work in Kitkat, the width is being ignored, the rectangle will fill the whole view.
I also tried to remove the second item, only leaves the first item, the width is still being ignored.
The ImageView uses this drawable:
<!--Width will be changed dynamically-->
<ImageView
android:id="@+id/someid"
android:layout_width="100dp"
android:layout_height="@dimen/someheight"
android:src="@drawable/the_xml_above"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:clickable="false"
/>
How to solve this?