当前位置: 移动技术网 > IT编程>移动开发>Android > Android ImageView 固定宽高比例的实现方法

Android ImageView 固定宽高比例的实现方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

暗之末裔漫画,邵传勇老婆,李斯丹妮全婐艺术照

android imageview 固定宽高比例的实现方法

本文主要介绍 imageview 固定宽高比例,

方法一:设置 adjustviewbounds="true",

方法二:使用 universal-image-loader 图片缓存类,需要注意的是方法二和方法一同时使用导致设置无效。

方法一:设置 adjustviewbounds="true"

<imageview
android:id="@+id/img_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustviewbounds="true" />

方法二:使用 universal-image-loader 图片缓存类

.imagescaletype(imagescaletype imagescaletype) 是设置图片的缩放方式,缩放类型 magescaletype:

imagescaletype.exactly // 图像将完全按比例缩小的目标大小
imagescaletype.exactly_stretched // 图片会缩放到目标大小完全
imagescaletype.in_sample_int // 图像将被二次采样的整数倍
imagescaletype.in_sample_power_of_2 // 图片将降低2倍,直到下一减少步骤,使图像更小的目标大小
imagescaletype.none //图片不会调整

注意:经过测试方法二和方法一同时使用导致设置无效。

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持,本站关于android 开发的文章还有很多,希望大家搜索查阅,大家共同进步!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网