Skip to content Skip to sidebar Skip to footer

Spinner's Background Image Appears Stretched

I have created a dropdown spinner with a background custom image. I have placed the spinner in a linear layout and I have aligned items using weight. Here is my code - XML -

Solution 1:

The background image takes all the given space - 1/3 of the the LinearLayout width. If you don’t want it to stretch, you could create a drawable layout, e.g. drawable/my_sort_icon:

<?xml version="1.0" encoding="utf-8"?><bitmapxmlns:android="http://schemas.android.com/apk/res/android"android:src="@drawable/ic_action_sort_by_size"android:tileMode="disabled"android:gravity="center" />

and use it as a background image in your Spinner:

<Spinner
    android:id="@+id/more"
    android:layout_width="0dp"
    android:layout_weight="1"
    android:background="@drawable/my_sort_icon"
    android:layout_height="@dimen/height"/>

Post a Comment for "Spinner's Background Image Appears Stretched"