Androidで画面の幅に対して指定した割合の幅の正方形を作成する
Android Studioを用いた開発で画面幅のx%の幅の正方形のビューがほしいときの記述
ConstraintLayoutを親にしてwidthとheightに0dpを指定
以下の2行をxmlに追加
app:layout_constraintWidth_percent="0.70"
app:layout_constraintDimensionRatio="H,1:1"
こんな感じになる
Android Studioを用いた開発で画面幅のx%の幅の正方形のビューがほしいときの記述
ConstraintLayoutを親にしてwidthとheightに0dpを指定
以下の2行をxmlに追加
app:layout_constraintWidth_percent="0.70"
app:layout_constraintDimensionRatio="H,1:1"
こんな感じになる