我想调整图像的大小以适应它填充整个宽度的屏幕。高度应设置为纵横比。例如,图像尺寸为宽x高 10x5,手机为 400 宽。图像应以 200x400 显示。
我玩了一些设置 android:scaleType="center" 根据文档应该是正确的设置,但似乎没有效果, android:scaleType="centerCrop" 适合高度并使宽度大于屏幕。
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageViewFrage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:padding="1dp"
android:scaleType="centerCrop"
android:src="@drawable/bg_striped_img" />
</LinearLayout>
</LinearLayout>
多谢