【发布时间】:2020-10-30 19:41:01
【问题描述】:
我在 Linearlayout 中有一个图像视图,我希望它的宽度为 fill_parent。我希望它的高度是最终的宽度。例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1:1"
android:scaleType="centerCrop"
android:layout_margin="2dp"
tools:ignore="Suspicious0dp" />
</LinearLayout>
但它不显示 android 布局中的图像.. 如果我在代码中强制将 imageview 的高度更改为 100dp,它会起作用,但我想知道为什么即使我写了 constraintDimensionRatio 1:1..
谢谢
【问题讨论】:
标签: android xml layout height width