我的图像可以是300x600px或600x300px。我想把它们放在一个50dp的盒子里。因此,根据图像的比例,图像将是25dp x 50dp或50x25dp
我试过各种各样的东西,我都快疯了
<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中赋予的任何值
发布于 2014-10-22 23:25:59
使用scaleType="fitCenter" (如果要放大小图像)或scaleType="centerInside" (否则)。
禁用adjustViewBounds。
https://stackoverflow.com/questions/22513940
复制相似问题