Android的布局FrameLayout默认是把布局内的子view堆砌在左上角,但是,可以通过设置子view的:
android:layout_gravity
此参数控制子view的布局位置,实现FrameLayout的各种子view布局位置,如左居中,右居中,居中等等,要点在android:layout_gravity的参数设置中组合使用“center”、“left”、“right”等,现在给出XML代码实例布局:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:text="左上角"
android:textColor="@android:color/white" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity=&#