はじめに
今回は XML内で面白いものはないかと遊んでいた所見つけた 比率で大きさ指定をする方法を記事に残しておきます。
実践
widthのサイズを基準にheightのサイズに合わせるか、逆にheightのサイズを基準にwidthのサイズに合わせるかを指定でき、widthのw か heightのhで指定する その後ろに,で区切り比率を数字で指定する。
android:layout_width="100dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="h,1:1"
上の例では widthをheightに合わせて1:1にするのでどちらも100dpになる。
注意としてConstraintsLayout内でしか使えないということがあげられます。