请看这段代码片段:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="35dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingRight="5dp"
android:scaleType="fitXY"
android:src="@drawable/1" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="5dp"
android:scaleType="fitXY"
android:src="@drawable/2" />
</LinearLayout>
</LinearLayout>
我在我的 Android 应用程序中使用此代码,主要基于图像。我对正确缩放有疑问。当我使用 scaleType="fitXY" (上面的代码)时,所有尺寸的一切看起来都很好,但不是图像的高度。宽度被正确拉伸,但高度没有。我尝试使用不会拉伸图像并保持比例正常的 centerInside。但是图像的大小存在问题——它们在某些设备上太小了。我的问题是 - 如何使基于图像的应用程序在所有设备上看起来都一样(或非常接近)?
样品:
http://i.stack.imgur.com/cjS5f.jpg 宽度和高度还可以,但是边距搞砸了,fitCenter http://i.stack.imgur.com/4BUTr.jpg 宽度还可以 - 但高度不行,适合XY