我在 TableLayout/TableRow 中有一个 ImageButton。
我想将 ImageButton 分布在整个 TableRow 上并将图片设置在按钮的中心(高度像 tablerow/button 高度)
我在布局文件中设置...
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow >
<ImageButton
android:id="@+id/CarPic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onButtonClick"
android:scaleType="centerInside"
android:src="@drawable/etype" />
</TableLayout>
当应用程序启动时,默认图片会像我描述的那样出现 - 但是当我使用 onclick 更改按钮的图片时...按钮调整为图片高度/宽度并停留在右上角
代码
Drawable d = Drawable.createFromPath(Path);
LPic.setImageDrawable(d);
我尝试了许多不同的版本:(填充和换行,但按钮会改变每张图片