相关疑难解决方法(0)

如何使用 ConstraintLayout 在 DimensionRatio 上设置 maxHeight?

我正在尝试显示以父级为中心的图像,尺寸比为 1220:1000,最大高度为 300dp(即使使用大屏幕也能保持图像小)

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/image"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:adjustViewBounds="true"
        android:scaleType="centerInside"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintDimensionRatio="1220:1000"
        app:layout_constraintHeight_max="200dp"  ==> This line break the ratio (the image is not displayed)
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

该app:layout_constraintHeight_max属性打破了比例。有没有办法做到这一点?

layout android android-constraintlayout

6
推荐指数
1
解决办法
1474
查看次数

标签 统计

android ×1

android-constraintlayout ×1

layout ×1