0

我正在创建一个具有固定底部面板的应用程序。每个面板的内容应显示在其上方的空间中。但是每当我用一些内容填充正文时,内容就会溢出并与底部面板重叠。

在此处输入图像描述

在我填充它之后,它看起来像这样: 在此处输入图像描述

代码如下:

<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."/>
</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="75dp"
    android:orientation="horizontal"
    android:layout_alignParentBottom="true"
    android:weightSum="3"
    android:layout_weight="0"
    android:id="@+id/bottompanel">
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_profile"
            android:layout_gravity="center"
            android:layout_weight="1"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Profile"
            android:layout_gravity="center"
            android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_bookings"
            android:layout_gravity="center"
            android:layout_weight="1"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Bookings"
            android:layout_gravity="center"
            android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_tournaments"
            android:layout_gravity="center"
            android:layout_weight="1"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Games"
            android:layout_gravity="center"
            android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">

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

    </LinearLayout>
</LinearLayout>

PS:我知道提供相同功能的库,但使用它们会使我对我的应用程序的控制更少。

4

3 回答 3

1

你必须像这样尝试,你不需要添加linerlayout作为textview的外部布局:

 <RelativeLayout xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:android="http://schemas.android.com/apk/res/android">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
    android:layout_above="@id/bottompanel"
                android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry...."/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="75dp"
            android:orientation="horizontal"
            android:layout_alignParentBottom="true"
            android:weightSum="3"
            android:layout_weight="0"
            android:id="@+id/bottompanel">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_weight="1">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_profile"
                    android:layout_gravity="center"
                    android:layout_weight="1"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Profile"
                    android:layout_gravity="center"
                    android:layout_weight="1"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_weight="1">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_bookings"
                    android:layout_gravity="center"
                    android:layout_weight="1"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Bookings"
                    android:layout_gravity="center"
                    android:layout_weight="1"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_weight="1">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_tournaments"
                    android:layout_gravity="center"
                    android:layout_weight="1"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Games"
                    android:layout_gravity="center"
                    android:layout_weight="1"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_weight="1">

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

            </LinearLayout>
        </LinearLayout>
 </RelativeLayout>
于 2018-02-15T05:47:30.550 回答
1

有很多方法可以做到

1)如果您的父布局是相对布局,仅用于底栏集属性

allignParentBottom="true"

你的另一个身体应该有

android:layout_above="@+id/bottom_bar"

2)将您的父布局设置为线性布局 orientation应该是垂直的并设置weightSum属性,例如weightSum = 6

并在您的身体布局中设置layoutHeight0dp和 并在您的底栏高度中设置为并weight根据您的要求 更改这些值5layoutHeight0dpweight1

3)使用 ConstraintLayout 了解更多详细信息,请查看这些链接链接

于 2018-02-15T05:48:40.867 回答
0

在父视图中给出顶视图的位置,android:layout_above="@+id/bottompanel"这将使文本保持在底视图之上。

<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout android:id="@+id/topPannel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/bottompanel"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout android:id="@+id/bottompanel"
    android:layout_width="match_parent"
    android:layout_height="75dp"
    android:orientation="horizontal"
    android:layout_alignParentBottom="true"
    android:weightSum="3"
    android:layout_weight="0">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_profile"
            android:layout_gravity="center"
            android:layout_weight="1"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Profile"
            android:layout_gravity="center"
            android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_bookings"
            android:layout_gravity="center"
            android:layout_weight="1"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Bookings"
            android:layout_gravity="center"
            android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_tournaments"
            android:layout_gravity="center"
            android:layout_weight="1"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Games"
            android:layout_gravity="center"
            android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">

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

    </LinearLayout>
</LinearLayout>
于 2018-02-15T05:46:57.413 回答