有我的按钮
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton1"
android:layout_weight="0.33" />
在此调用setImageBitmap()之后,宽度正在改变。如何设置恒定宽度?
答案 0 :(得分:1)
201
改变它。
答案 1 :(得分:0)
而不是int
,将宽度设置为您想要的固定宽度:<ImageButton
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="@+id/imageButton1"
android:layout_weight="0.33" />
如果您希望它是总宽度的三分之一,请将宽度设置为0.
答案 2 :(得分:0)
使用
android:minWidth="200dp"
android:maxWidth="200dp"