2014-03-19 151 views
0

我的图像可能是300x600px或600x300px。我希望它们以50dp的方式显示。因此图像会25dp X 50dp或50x25dp取决于其比使用scaleType疯狂

我曾尝试过各种东西,我要疯了

<RelativeLayout 
    android:layout_width="50dp" 
    android:layout_height="50dp"> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/image"/> 
</RelativeLayout> 

(不裁剪什么... )

<ImageView 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:scaleType="centerCrop" 
     android:adjustViewBounds="true" 
     android:background="@drawable/image"/> 

但没有工作,我好像把什么值scaleType被忽略

+0

看看[这个](http://stackoverflow.com/questions/19485680/how-to-scale-an-image-down-in-android)作品 – AndyFaizan

+0

所以你不能通过XML来做到这一点? – Thomas

回答

0

使用scaleType="fitCenter"(如果您想要放大小图像)或scaleType="centerInside"(否则)。

Disable adjustViewBounds