Android for Android上的图像缩放不一致:scaleType =“fitCenter”

时间:2012-01-29 09:24:25

标签: android image image-scaling

我想显示带边框的图像。下面的解决方案适用于某些图像,但不适用于其他图像。

到目前为止,我最好的猜测是,它适用于较小的图像,但不适用于较大的图像。

使用较小的图片,解决方案可以很好地显示图像,边框为2像素。背景太大,背景太宽了。

我正在使用我手动缩放的图像进行测试,例如2000 * 400到200 * 40.所以它是相同的图像,只是预分频。

任何想法为什么大图片的缩放方式与小图片的缩放方式相同?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:background="#ffffff"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              android:gravity="center" >

    <ImageView
            android:id="@+id/testimage"
            android:background="#000000"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/testimage2"
            android:padding="2dip"
            android:scaleType="fitCenter"
            />
</LinearLayout>

1 个答案:

答案 0 :(得分:5)

删除scaletype并为您的Imageview使用android:adjustViewBounds =“true”。