如何自动居中裁剪 ImageView Android? [英] How to auto center crop ImageView Android?

查看:30
本文介绍了如何自动居中裁剪 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆