我遵循了每一种方法但对我没有任何作用。
在这种情况下,我有五个ImageButtons
在行中,每个都有一个图标和背景可绘制:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:orientation="horizontal"
android:weightSum="5" >
<ImageButton
android:id="@+id/food"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:padding="20dp"
android:scaleType="fitCenter"
android:layout_marginRight="2dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:background="@drawable/chooser_effect"
android:src="@drawable/restaurant_icon" />
这是我的一个imageButtons,其他是相同的。
当我在我的有源设备Samsung S5上测试这个布局时,效果很好。由于我希望我的图标适合大约75%的按钮填充和scaleType是准确的,但是,当我在模拟器上运行我的应用程序,屏幕尺寸小,图标太小,“太小”,我的意思是他们无法在所有。我尝试了所有其他解决方案,我发现它使用android:scaleYpe="fitXY"
,但后来我的图标太大了,它们的分辨率质量也被弃用了。任何线索?