How To Specify Width And Height Of A Drawable Item
Hi is there anyway of providing width and height of a drawable defined in drawable.xml in drawable folder. Example: Copy
Solution 2:
You can use attribute width
and height
in API level 23 and higher:
<itemandroid:width="18dp"android:height="18dp"android:drawable="@drawable/icon_ratingstar"/>
For lower API levels, I do not know a way of specifying width
and height
directly. The best practice is scaling drawables as far as I know.
Solution 3:
You can specify inside the <item>
tag the width
and height
of the drawable
:
<selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_pressed="true"android:width="100dp"android:height="20dp"android:drawable="@drawable/button_pressed" /><!-- pressed --><itemandroid:state_focused="true"android:width="100dp"android:height="20dp"android:drawable="@drawable/button_focused" /><!-- focused --><itemandroid:drawable="@drawable/button_normal" /><!-- default -->
Post a Comment for "How To Specify Width And Height Of A Drawable Item"