`
helpbs
  • 浏览: 1154968 次
文章分类
社区版块
存档分类
最新评论

layout中设置图片自适应大小,并且设置最大宽高

 
阅读更多
ayout中设置图片自适应大小,并且设置最大宽高,当图片的宽高大于设置的最大值时,宽高值为设置的最大值。

Java代码收藏代码
  1. <ImageViewandroid:id="@+id/image_view"
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. android:adjustViewBounds="true"
  5. android:maxWidth="42dp"
  6. android:maxHeight="42dp"
  7. android:scaleType="fitCenter"
  8. android:layout_marginLeft="3dp"
  9. android:src="@drawable/icon"
  10. />

关键代码:

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxWidth="42dp"
android:maxHeight="42dp"
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics