Android 以“3”开头的问题;“行”;在布局中,中间一个最大化

Android 以“3”开头的问题;“行”;在布局中,中间一个最大化,android,android-layout,android-linearlayout,Android,Android Layout,Android Linearlayout,我正在尝试创建一个包含3个主要行的布局。我正在使用ActionBarFragment(来自v7 Compatibility)。我尝试了我能想到的线性和相对布局的每一种组合。当我只有按钮1时,它就工作了,但当我加上按钮2和3时,它就不工作了。我尝试将功能(EditText和3个按钮)包装到自定义视图类中(使用合并布局文件扩展RelativeLayout) 所需外观: | actionbar | +--------------------+ | infobar

我正在尝试创建一个包含3个主要行的布局。我正在使用ActionBarFragment(来自v7 Compatibility)。我尝试了我能想到的线性和相对布局的每一种组合。当我只有按钮1时,它就工作了,但当我加上按钮2和3时,它就不工作了。我尝试将功能(EditText和3个按钮)包装到自定义视图类中(使用合并布局文件扩展RelativeLayout)

所需外观:

| actionbar          |
+--------------------+
| infobar            |
+--------------------+
| staggered          |
| grid view          |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
+--------------------+
|          | button1 |
| EditView | button2 |
|          | button3 |
我的当前结果与交错视图、编辑文本和按钮周围的相对布局

| actionbar          |
+--------------------+
| infobar            |
+--------------------+
| staggered          |
| grid view          |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
| actionbar          |
+--------------------+
| infobar            |
+--------------------+
|          | button1 |
|          | button2 |
|          | button3 |
|          |         |
|          |         |
|          |         |
| EditView |         |
|          |         |
|          |         |
|          |         |
|          |         |
|          |         |
|          |         |
使用线性布局包围栅格视图和编辑文本/按钮时会产生

| actionbar          |
+--------------------+
| infobar            |
+--------------------+
| staggered          |
| grid view          |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
| actionbar          |
+--------------------+
| infobar            |
+--------------------+
|          | button1 |
|          | button2 |
|          | button3 |
|          |         |
|          |         |
|          |         |
| EditView |         |
|          |         |
|          |         |
|          |         |
|          |         |
|          |         |
|          |         |
我的当前布局:活动的布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/eventActivityLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:showDividers="middle" >

    <RelativeLayout
        android:id="@+id/infoBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#AAA" >

        <TextView
            android:id="@+id/left_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="3dp"
            android:textSize="12sp" />

        <TextView
            android:id="@+id/right_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@+id/left_text"
            android:gravity="right"
            android:padding="3dp"
            android:textAlignment="viewEnd"
            android:textSize="12sp" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <com.example.EventStaggeredGridView
            android:id="@+id/gridView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <com.example.EventCreatePostView
            android:id="@+id/eventCreatePost"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/gridView"
            android:background="#EEE" />
    </RelativeLayout>

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:id="@+id/postRow"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <EditText
            android:id="@+id/postMessageText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="false"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/buttons"
            android:bufferType="spannable"
            android:hint="@string/share"
            android:imeOptions="actionDone"
            android:inputType="textCapSentences|textMultiLine" />

        <LinearLayout
            android:id="@+id/buttons"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="false"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:orientation="vertical" >

            <Button
                android:id="@+id/postMessageButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/post" />

            <ImageButton
                android:id="@+id/cameraButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/attach_photo_from_camera_or_gallery"
                android:src="@drawable/ic_action_camera" />

            <ImageButton
                android:id="@+id/videoButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/attach_video_from_camera_or_gallery"
                android:src="@drawable/ic_action_video" />
        </LinearLayout>
    </RelativeLayout>

</merge>

底视图的布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/eventActivityLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:showDividers="middle" >

    <RelativeLayout
        android:id="@+id/infoBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#AAA" >

        <TextView
            android:id="@+id/left_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="3dp"
            android:textSize="12sp" />

        <TextView
            android:id="@+id/right_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@+id/left_text"
            android:gravity="right"
            android:padding="3dp"
            android:textAlignment="viewEnd"
            android:textSize="12sp" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <com.example.EventStaggeredGridView
            android:id="@+id/gridView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <com.example.EventCreatePostView
            android:id="@+id/eventCreatePost"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/gridView"
            android:background="#EEE" />
    </RelativeLayout>

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:id="@+id/postRow"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <EditText
            android:id="@+id/postMessageText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="false"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/buttons"
            android:bufferType="spannable"
            android:hint="@string/share"
            android:imeOptions="actionDone"
            android:inputType="textCapSentences|textMultiLine" />

        <LinearLayout
            android:id="@+id/buttons"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="false"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:orientation="vertical" >

            <Button
                android:id="@+id/postMessageButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/post" />

            <ImageButton
                android:id="@+id/cameraButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/attach_photo_from_camera_or_gallery"
                android:src="@drawable/ic_action_camera" />

            <ImageButton
                android:id="@+id/videoButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/attach_video_from_camera_or_gallery"
                android:src="@drawable/ic_action_video" />
        </LinearLayout>
    </RelativeLayout>

</merge>

尝试使用
RelativeLayout
作为父容器,并进行以下更改:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/eventActivityLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:id="@+id/infoBar"
        android:layout_width="match_parent"
        android:layout_alignParentTop="true"
        android:layout_height="wrap_content"
        android:background="#AAA" >

        <TextView
            android:id="@+id/left_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="3dp"
            android:textSize="12sp" />

        <TextView
            android:id="@+id/right_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@+id/left_text"
            android:gravity="right"
            android:padding="3dp"
            android:textAlignment="viewEnd"
            android:textSize="12sp" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/gridView"
        android:layout_below="@+id/infoBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <com.example.EventStaggeredGridView
            android:id="@+id/gridView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <com.example.EventCreatePostView
            android:id="@+id/eventCreatePost"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/gridView"
            android:background="#EEE" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/postRow"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <EditText
            android:id="@+id/postMessageText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="false"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/buttons"
            android:bufferType="spannable"
            android:hint="@string/share"
            android:imeOptions="actionDone"
            android:inputType="textCapSentences|textMultiLine" />

        <LinearLayout
            android:id="@+id/buttons"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="false"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:orientation="vertical" >

            <Button
                android:id="@+id/postMessageButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/post" />

            <ImageButton
                android:id="@+id/cameraButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/attach_photo_from_camera_or_gallery"
                android:src="@drawable/ic_action_camera" />

            <ImageButton
                android:id="@+id/videoButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/attach_video_from_camera_or_gallery"
                android:src="@drawable/ic_action_video" />
        </LinearLayout>
    </RelativeLayout>



</RelativeLayout>