首页 Android Android之ImageView高度自适应的解决方案

Android之ImageView高度自适应的解决方案

作者:胡同里的砖头 围观群众:248 更新于:2022-12-12

ImageView高度使用wrap_content,上下高度会空白很多,如图显示


如何让图片高度自适应,只需要加入如下两个参数
android:scaleType="fitXY"
android:adjustViewBounds="true"
即可,整体代码如下:

<ImageView
android:id="@+id/thing_show_image"
android:layout_width="match_parent" android:scaleType="fitXY"
android:layout_height="wrap_content" android:adjustViewBounds="true"
tools:src="@tools:sample/backgrounds/scenic" />
效果如图

  • 本文标题: Android之ImageView高度自适应的解决方案
  • 文章分类:【Android】
  • 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.
留言评论
站点声明:
1、本站【胡同里的砖头】个人博客,借鉴网上一些博客模板,取其各优点模块自行拼装开发,本博客开发纯属个人爱好。
2、所有笔记提供给广大用户交流使用,可转载,可复制,纯个人开发所遇问题锦集记录使用
Copyright © huzlblog.com All Rights Reserved. 备案号:苏ICP备2021056683号-8