这是通过RelativeLayout 完成的。在 RelativeLayout 内部,您可以将视图放置在您想要的任何位置。在这种情况下,您将 Google Plus 标题粘贴到父级顶部,将评论栏粘贴到父级底部。在这两个视图之间放置一个 ScrollView,其中包含图像、元标记和对照片的评论。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/actionbar"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:textSize="20dp"
android:text="Google Plus ActionBar" />
<TextView
android:id="@+id/commentbar"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:textSize="20dp"
android:text="Add Comment Bar" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/actionbar"
android:layout_above="@id/commentbar">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="500dp"
android:background="#00ff00" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#0000ff" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#ff0000" />
</LinearLayout>
</ScrollView>
结果(绿色视图应代表图像,蓝色和红色视图应代表评论):
