How can I stretch the image in imagebutton to the whole area of the imagebutton?

前端 未结 7 819
感情败类
感情败类 2021-02-01 18:09

Here is a picture that will help you understand my problem:

\"It's

I want to stretch

相关标签:
7条回答
  • You should consider creating a 9-patch image to make the image fit correctly on an ImageButton in case you need to stretch it, but you don't want the image to become distorted.

    To have a button with an image that completely covers it, you can use something like this:

    <ImageButton android:id="@+id/iconBtn"
      android:layout_width="64dip"
      android:layout_height="64dip"
      android:src="@drawable/icon_button"
      android:scaleType="fitCenter"
      android:background="#00000000"/>
    

    For a full tutorial on creating buttons with custom skins and the use of selectors to manage their states, you can check a tutorial I've written some time ago here (Creating a custom Android button with a resizable skin).

    0 讨论(0)
提交回复
热议问题