当前位置:网站首页>Layout of code setting constraintlayout_ constraintDimensionRatio

Layout of code setting constraintlayout_ constraintDimensionRatio

2022-06-11 07:56:00 tinyvampirepudge

Set... In the code layout_constraintDimensionRatio:

ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(mRlContent);
constraintSet.setDimensionRatio(R.id.iv,"h,9:16");
constraintSet.applyTo(mRlContent);

Corresponding layout :

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/iv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:contentDescription="@null"
        app:layout_constraintTop_toTopOf="parent"
        tools:background="@drawable/ic_launcher" />

    ...
</androidx.constraintlayout.widget.ConstraintLayout>

Reference resources :
https://www.jianshu.com/p/16e34f919e1a

原网站

版权声明
本文为[tinyvampirepudge]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110747210500.html