我如何防止ImageButton
有固定大小?选择器中使用的可绘制对象具有不同的大小,我希望ImageButton
自动调整大小以匹配图像大小。
我尝试了adjustViewBounds
但没有成功。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp" >
<ImageButton
android:id="@+id/picture_imagebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/tab_background_selector" />
</RelativeLayout>
ImageButton
,还可以尝试使用ImageView
。只要涉及设置图像,就可以使用ImageView
。 - GrIsHuImageButton
的源是一个选择器,在更改图像时没有涉及Java代码。 - gdelenteadjustViewBounds
关掉。这会使你的ImageButton
边界缩小到与当前图像一样大。 - Jason Robinson