【发布时间】:2012-07-10 02:30:52
【问题描述】:
我想调整图像的大小以适应屏幕以填充整个宽度。高度应设置为纵横比。 例如图像尺寸是宽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>
非常感谢
【问题讨论】: