Android 5 seems to be ignoring the gravity on a drawable xml

25 views Asked by At

I have a drawable xml that will be used as the background for some views. It will add a border to the view and put an icon on the right hand side. This is working fine on newer Android versions but on Android 5 it is displaying the icon in the middle.

This is the Drawable xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <layer-list>
            <item>
                <shape>

                    <padding android:left="8dp" android:right="8dp" />
                    <stroke android:color="@color/somecolor" android:width="2dp" />
                </shape>
            </item>
            <item android:drawable="@drawable/ic_keyboard_arrow_down_text_color_24dp" android:width="24dp" android:height="24dp" android:gravity="right|center_vertical">
            </item>
        </layer-list>
    </item>
</selector>

It appears that android:gravity="right|center_vertical" is ignored on the <item> that is just an icon.

Any idea how to fix this?

Thanks.

0

There are 0 answers