android - Drawable inside Button is getting enlarged -


for reason, need use button both icon , text. can't use imagebutton , go solution set drawabletop of normal button.

the button size 140dp in square shape (please refer screenshot below)

the planning use 125x125 px , asset clear , crisp.

however, 125px asset somehow being enlarged button, screenshot shown below.

the device xhdpi device.

as can see, icon inside square button blurry looks being somehow enlarged

enter image description here

here pasted button xml

<button                 android:id="@+id/button_call_us"                 android:layout_width="140dp"                 android:layout_height="140dp"                 android:layout_margin="@dimen/main_menu_button_margin"                 android:adjustviewbounds="true"                 android:background="@drawable/custom_button"                 android:drawablepadding="-20dp"                 android:drawabletop="@drawable/button_call_us_icon"                 android:lines="2"                 android:paddingtop="0dp"                 android:scaletype="fitxy"                 android:text="call us"                 android:textcolor="@color/white"                 android:textsize="6pt" /> 

the android:background="@drawable/custom_button" purple colour background without patterns.

the android:drawabletop="@drawable/button_call_us_icon" icon.

except android:scaletype="fitxy", have tried centerinside , other options, still not getting ideal result. question is:

why drawable inside button being enlarged? there way stop it?

thanks

since it's button, , want drawable inside button. probable solution use imagebutton implements drawable properties. can call android:scaletype="fitcenter" , set padding too

<imagebutton         android:id="@+id/imagebutton1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/android_button" /> 

however, more freedom in terms of desing, use simple layout instead of button, on lines of this, treat linearlayout button, in terms of adding onclicklistener:

<linearlayout android:orientations="vertical"     android:layout_height="wrap_content"     android:layout_width="wrap_content"     android:orientation="vertical"     android:background="#ccc"     android:padding="8dp"     android:gravity="center">     <imageview android:src='@drawable/ic_launcher'         android:layout_width="wrap_content"         android:layout_height="wrap_content" />     <textview android:text="lorem ipsum"         android:layout_height="wrap_content"         android:layout_width="wrap_content" /> </linearlayout> 

enter image description here


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -