如何解决实际视图的高度不符合适当的内容
| 我有一个ImageView,它显示资源中的图像。 ImageView的宽度是固定的(60dp)。高度设置为wrap_content。 调整图像大小以适合此宽度(节省宽高比-完美) 问题在于,android在调整大小之前将实际高度设置为图像的高度。但是我希望此图像的宽度和高度精确地为60dp,在调整大小后应等于图像的高度。 这是布局<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:orientation=\"vertical\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\">
<ImageView
android:layout_width=\"60dp\"
android:layout_height=\"wrap_content\"
android:src=\"@drawable/sample\"
android:background=\"#F0F0\"/>
</LinearLayout>
解决方法
尝试android:adjustViewBounds = \“ true \”
, 解决方案非常简单,我为ImageView标签添加了属性“ 1”。
, 有两种解决方案
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:orientation=\"vertical\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\">
<ImageView
android:layout_width=\"60dip\"
android:layout_height=\"wrap_content\"
android:background=\"@drawable/thumb\"
android:adjustViewBounds=\"true\"/>
</LinearLayout>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。