我的图像可以是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
中的任何价值都被忽略了
答案 0 :(得分:0)
使用scaleType="fitCenter"
(如果您想要放大小图片)或scaleType="centerInside"
(否则)。
禁用adjustViewBounds
。