如何将从SD卡加载的图像缩放到图像视图?

时间:2012-08-04 22:30:22

标签: android android-layout android-intent

我想将从SD卡加载的图像缩放到图像视图中。

问题是每当我从SD卡加载图像全屏时,我已根据其他问题设置了所有参数fill_parent viewbounds scaletype等。

应该怎样做?

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/Frame"
    android:layout_alignLeft="@+id/Load1"
    android:adjustViewBounds="true"
    android:cropToPadding="true"
    android:scaleType="fitXY"
    android:src="@android:drawable/alert_light_frame" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="14dp"
    android:scaleType="fitXY"
    android:src="@android:drawable/alert_light_frame" />

这是我的图片查看代码可以告诉我要更改的内容,以便根据图像视图大小来显示图像

2 个答案:

答案 0 :(得分:0)

使用fitCenter scaleType。在您的布局定义中,使用ImageView

的以下属性
android:scaleType="fitCenter"

答案 1 :(得分:0)

如果imageview很大,如果你试图加载一个大图像,那么布局正在做它应该做的事情。

因此,要么为ImageView而不是wrap_content提供固定的宽度/高度,要么根据手机的屏幕大小缩放图像。

试试此链接:How to scale down the image for better quality on Android? 以及这里的一些提示:How to scale an Image in ImageView to keep the aspect ratio