我正在动态地将图像加载到屏幕上的图像按钮上.图像将不会提前知道并且是差异大小.
有谁知道如何确保图像按钮大小保持不变,无论分配给它的图像是什么.优选地拉伸图像以适合按钮.我已经尝试使用android:scaleType ="fitXY"并将ewidth和height设置为硬值(不是更可取).无论我做什么,图像都决定了按钮的大小,反之亦然!救命!
我尝试了以下的组合.这些图像是从互联网搜索中随机出现的.
<ImageButton
android:id="@+id/ImageButton1"
android:layout_height="93px"
android:src="@drawable/image1"
android:layout_width="93px"
android:background="93px" />
<ImageButton
android:id="@+id/ImageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image1"
android:scaleType="fitXY" />
Run Code Online (Sandbox Code Playgroud)
非常感谢任何帮助!