aşağıdaki düzen dosyasını inceleyin: layout_constraintDimensionRatio çalışır:ConstraintLayout boy oranı
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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="match_parent">
<android.support.constraint.ConstraintLayout
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#0000FF"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintDimensionRatio="H,3:1"
tools:layout_editor_absoluteX="16dp" />
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
Ben app nasıl emin değilim. Benim anlayışım her zaman genişlik olacak: yükseklik. Dolayısıyla 3: 1, ImageView'ı daima 3 kattan daha geniş gösterecektir. H veya W öneki ConstraintLayout'a hangi boyutun orana uyması gerektiğini söyler. Eğer H ise o zaman genişlik ilk önce diğer kısıtlardan hesaplanacak ve yükseklik en boy oranına göre ayarlanacaktır.
yüksekliği beklenmedik bir genişliğinden 3 kat daha büyüktür: Bununla birlikte, bu düzen bir sonucudur. Birinin boyutların uygulamaya göre nasıl hesaplandığını açıklayabilir miyim: layout_constraintDimensionRatio ayarı?