Fit Image in ImageButton in Android

后端 未结 8 2223
猫巷女王i
猫巷女王i 2020-11-28 01:15

I have 6 ImageButton in my activity, I set images through my code in them ( not using xml).

I want them to cover 75% of the button area. But where as some images cov

相关标签:
8条回答
  • 2020-11-28 01:44

    I'm using the following code in xml

    android:adjustViewBounds="true"
    android:scaleType="centerInside"
    
    0 讨论(0)
  • 2020-11-28 01:44

    It worked well in my case. First, you download an image and rename it as iconimage, locates it in the drawable folder. You can change the size by setting android:layout_width or android:layout_height. Finally, we have

     <ImageButton
            android:id="@+id/answercall"
            android:layout_width="120dp"
            android:layout_height="80dp"
            android:src="@drawable/iconimage"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:scaleType="fitCenter" />
    
    0 讨论(0)
提交回复
热议问题