In Android, how to place image at center on a button without stretching? -
in android layout file, have button. , want present image button without text. problem have is, image stretched cover whole button area. instead of stretching, i'd have button placed @ center of button without distortion image.
<button android:layout_width="38dp" android:layout_height="match_parent" android:background="@drawable/icon_more" android:id="@+id/button" android:layout_alignparenttop="true" android:layout_alignparentend="true" />
right now, looks this:
it's horizontally stretched, not want.
using imagebutton choice you. can try:
<imagebutton android:layout_width="38dp" android:layout_height="match_parent" android:src="@drawable/icon_more" android:scaletype="centerinside" />
flexibly combining attributes layout_width, layout_height , scaletype helps ui
Comments
Post a Comment