res/layout/*.xmlについて

あるViewは可能な限り大きく、そうでないViewは最小限の表示

android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" →Layout内で大きく表示したいもの
android:layout_width="wrap_content" android:layout_height="wrap_content" →最小限表示するもの


2つのViewがwrap_contentである事が重要

2つ以上のViewを同じ大きさで表示

android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"


全てのViewに同じものを設定する。

2つ以上のViewで、全て同じ大きさで、一部だけ大きくしたい

同じ大きさにするもの
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"

違う大きさにするもの
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.7"


weightを小さくするとその分大きくなる。

fill_parent

とりあえず画面で表示可能な部分まで拡大して表示される。
画面以上のサイズにはならない。

また、fill_parentなViewをLinearLayoutなんかに2つ入れると、2つ目のViewは画面外に表示される事になるので注意。
Activity.findViewByIdで取得可能だけど表示されてねーなーと思ったら画面外にViewがある可能性を疑うべき。

wrap_content

そのUIが表示できる最小限のサイズ?

画面の中央に何かを表示させたい

FrameLayoutの場合、中のViewに対してandroid:layout_gravity="center"を行う。

android: gravity

自分の子要素の位置を決定する。