矛盾的图像缩放为Android:scaleType =“fitCenter”

问题描述:

我想与边框来显示图像。下面的解决方案适用于某些图像,但不适用于其他图像。矛盾的图像缩放为Android:scaleType =“fitCenter”

到目前为止,我最好的猜测是,它工作正常较小的图像,而不是路数。

随着较小的图片,将溶液很好地显示图像用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> 
+0

你可能想尝试scaleType的所有组合。 – 2012-01-29 10:41:53

+0

这就是我所做的,并以fitCenter结束。我确信它是正确的,但事实并非如此。 – tzrnee 2012-01-30 08:14:02

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

+0

是的,这工作正常。谢谢! – tzrnee 2012-01-30 08:02:38