【发布时间】:2016-02-16 10:41:12
【问题描述】:
我有一个 imageView,我希望它尽可能大,限制它的高度,并保持它的纵横比,我的问题是它得到了它可以忽略我设置的 maxHeight 的整个空间。这是代码:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:maxHeight="100dp"
android:adjustViewBounds="true"
android:src="@drawable/ic_profile"/>
</LinearLayout>
为什么在adjustViewBounds 为true 时忽略maxHeight 事件?我该如何解决这个问题?
提前致谢!
【问题讨论】:
-
尝试为 LinearLayout 设置 android:maxHeight="100dp" 并从图像视图中删除该行。
-
试试
android:scaleType="centerInside"到ImageView -
感谢您的回答,我试过了,但没有解决问题:(
标签: android android-layout android-imageview android-image