LoginSignup
0
0

More than 1 year has passed since last update.

ConstraintLayoutでViewの最小(最大)サイズの設定をする

Posted at

はじめに

ConstraintLayoutとNestedScrollViewを使ってレイアウト作成している際に以下のような問題が発生。

  • 上下のViewの大きさを固定してそのほかの領域に最大サイズであるViewAを表示したい
  • 解像度の低い端末ではViewAの表示領域が非常に小さくなってしまうため最低表示する高さを指定したい

行ったこと

android:minHeight = "xxdp"

上記を追加

引っかかった点と解決法

  • minHeightが効かない
  • 各端末ごとに調査した結果Viewが崩れることが多々ある

1. まずそもそもlayout_constrainedHeightがないと適用されない

app:layout_constrainedHeight="true"

2. android:layout_heightはwrap_content

android:layout_height="wrap_content"

ほか制約をつけており0dpに設定していることがよくあるがwrap_contentの必要がある

3. maxHeightは別にいらない

見る記事によってはどっちも必要だという記述もありましたが試したところしっかり制約つけていれば両方揃わないと片方が適用されないなんてことはありませんでした

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0