【发布时间】:2015-08-11 03:55:21
【问题描述】:
我有以下 xml 文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/topFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:id="@+id/imageViewTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_00" />
<TextView
android:id="@+id/textViewTest"
android:layout_below="@+id/imageViewTest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is a Test"/>
</RelativeLayout>
<FrameLayout
android:id="@+id/bottomFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal" />
</LinearLayout>
- 第一个 FrameLayout 包含一个片段,其中包含一些按钮。
- RelativeLayout 包含例如图像(更改大小)和文本。
- 最后一个 FrameLayout 还包含一个片段,其中包含一些按钮或一些文本或图像。
我的目标是: - 第一个 FrameLayout 在顶部(有效) - RelativeLayout 中的元素在屏幕中间居中(不起作用) - 最后一个 FrameLayout 在底部(不起作用)
应该是这样的:
我之前在RelativeLayout 和android:layout_gravity="bottom|center_horizontal" 中使用android:gravity="center" 的第二次FrameLayout 尝试失败了。
【问题讨论】:
标签: java android xml android-layout android-fragments