1. 程式人生 > >Android開發, 子容器/元件在RelativeLayout和LinearLayout中居中

Android開發, 子容器/元件在RelativeLayout和LinearLayout中居中

這裡說的是在子容器/元件中的設定。
如果父容器是 LinearLayout的話,在子容器/元件中的設定應為

android:layout_gravity="center"

如果父容器是 RelativeLayout的話,在子容器/元件中的設定應為

android:layout_centerInParent="true"

先簡單記錄下,具體的區別日後再研究。