I have a relative layout with some ImageViews that sometimes extend beyond the layout's boundaries. When this happens the ImageView开发者_运维问答s get resized so they become smaller instead of extend out of bounds. I want them to display normally and just get cropped.
I think there is some kind of boolean to do that, but I can't find it in the API. I thought it might be clipChildren under ViewGroups, but setting that to false or true seems to do nothing. Anyone help is appreciated.
A little bit late but have you tried this code in your xml?
<ImageView
android:scaleType="centerCrop"
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
The key is in scaleType. It keeps the aspect ratio of your image cropping it to the bounds of layout.
精彩评论