【发布时间】:2012-08-07 19:38:55
【问题描述】:
我想在我的屏幕设备上放置一个 Y 边距较大的 ImageView,这意味着图像的一部分会超出屏幕,然后图像会被裁剪。
问题是 Android 一直在缩放图像,以便它适合屏幕,但我不希望这样,我希望图像被裁剪。
如何强制 ImageView 被裁剪而不调整大小?
附:我尝试了所有可能的 ScaleType 属性,但没有一个对我有用!
代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:background="@drawable/my_image"
android:scaleType="centerCrop"
/>
</RelativeLayout>
【问题讨论】:
-
等等。 CENTER_CROP 应该保持图像正常大小而不进行任何缩放。请发布代码。
-
我刚刚在我的问题中添加了一些代码。 CENTER_CROP 对我不起作用。
标签: android scaling android-imageview crop