现在的需求是。ImageView最高20dp。保持长宽比。
用height=20,width=wrap_content是不能解决问题的。这个时候就需要用到maxHeight
和adjustViewBounds
这两个属性了。看下代码:
<ImageView
android:id="@+id/iautos_iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxHeight="20dp"
android:adjustViewBounds="true"
android:clickable="true"
android:src="@mipmap/iautos"/>
注意这里的width和height都是wrap_content
网友评论