2

我创建了下面的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativeStart"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/back"
    tools:context=".SongsActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/header"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="horizontal">

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@null"
                android:src="@drawable/felesh_m" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center_horizontal|center_vertical"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <ImageButton
                    android:id="@+id/imbCenter"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:background="@null"
                    android:src="@drawable/hosein_hlarge" />
            </LinearLayout>

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@null"
                android:src="@drawable/felesh_m" />
        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="4" />
    </LinearLayout>
</RelativeLayout>

见下图:

在此处输入图像描述

4

1 回答 1

4

像这样改变你的布局。您不需要采取多个Linear Layouts. 这对性能不利。所以我把它改成了单一Linear Layout的,有一些Weight属性。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativeStart"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/common_ic_googleplayservices">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/common_ic_googleplayservices"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="3"
            android:orientation="horizontal">

            <ImageButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.50"
                android:background="@null"
                android:src="@drawable/common_ic_googleplayservices" />


            <ImageButton
                android:id="@+id/imbCenter"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:background="@null"
                android:src="@drawable/common_ic_googleplayservices" />

            <ImageButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0.50"
                android:background="@null"
                android:src="@drawable/common_ic_googleplayservices" />
        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="4" />
    </LinearLayout>
</RelativeLayout>

在此处输入图像描述

于 2016-09-08T08:14:40.530 回答