How to auto center crop ImageView Android?(如何自动居中裁剪 ImageView Android?)
问题描述
我做了一个 listView 图像.我的目标是我的 listView 的每个项目都具有相同的 100dp 高度.我遇到了一个问题,我的 imageView 会自动调整大小,但不会占用父级的整个空间.
I made a listView images. My goal that each item of my listView have the same height of 100dp. I encounter a problem that my imageView is resized automatically, but does not take the entire space of the parent.
这是我目前的结果和 objectif 结果:
有谁知道添加自动裁剪中心的选项吗?
推荐答案
我不确定我是否理解正确.我猜它一定是你想要的两者中的任何一个.
I am not sure if I understood correctly. It must be either of the two, that you want, I guess.
在你的图像视图中设置属性
In your image view set the attribute
android:scaleType="fitXY"
完全适合ImageView
.
你可以选择
android:scaleType="centerCrop"
裁剪中心.
这篇关于如何自动居中裁剪 ImageView Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!