MacaronLover MacaronLover - 4 years ago 182
Android Question

How to set width of layer-list as a whole?

How can I specify the width of an XML drawable when using a

layer-list
? I want the width of the drawable (as a whole) to be set to 20dp but I don't where/how to set this + the preview pane doesn't help that much either.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/blue" />
</shape>
</item>
<item android:left="8dp" android:right="8dp">
<shape>
<solid android:color="#fff" />
</shape>
</item>
</layer-list>


enter image description here

Answer Source

you can try this

    <shape>
        <solid android:color="#fff" />
        <size android:height="10dp" android:width="20dp"/>
    </shape>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download