java - 线性布局与另一个线性布局重叠

标签 java android user-interface

我在一个RelativeLayout中有两个LinearLayouts,问题是顶部的线性布局与底部的线性布局有一点重叠。我尝试了一切。请有人帮助我。下面是我的 XML 文件 或者告诉我如何以编程方式完成它。就像从一个线性布局中减去另一个线性布局的高度一样。

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:weightSum="1">

        <FrameLayout
            android:id="@+id/page_fragment"
            android:layout_width="150dp"
            android:layout_height="match_parent"
            android:background="@color/spinner_text_color" />

        <FrameLayout
            android:id="@+id/detail_fragment"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@color/white_bg"
            android:layout_weight="1"></FrameLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/spinner_text_color">

        <Button
            android:id="@+id/filterResetButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".50"
            android:textColor="@color/white_bg"
            android:textAllCaps="false"
            android:background="@drawable/light_button_click"
            android:text="Reset All" />

        <Button
            android:id="@+id/filterApplyButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".50"
            android:textAllCaps="false"
            android:background="@drawable/submit_order_click"
            android:textColor="@color/white_bg"
            android:text="Apply" />

    </LinearLayout>

</RelativeLayout>

最佳答案

试试这个:

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:weightSum="1"
        android:layout_above="@+id/linearLayout">

        <FrameLayout
            android:id="@+id/page_fragment"
            android:layout_width="150dp"
            android:layout_height="match_parent"
            android:background="@color/colorPrimary" />

        <FrameLayout
            android:id="@+id/detail_fragment"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@color/white"
            android:layout_weight="1"></FrameLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/colorPrimary"
        android:id="@+id/linearLayout">

        <Button
            android:id="@+id/filterResetButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".50"
            android:textColor="@color/white"
            android:textAllCaps="false"
            android:background="@drawable/ic_authy"
            android:text="Reset All" />

        <Button
            android:id="@+id/filterApplyButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".50"
            android:textAllCaps="false"
            android:background="@drawable/ic_arrow_32"
            android:textColor="@color/white"
            android:text="Apply" />

    </LinearLayout>

</RelativeLayout>

关于java - 线性布局与另一个线性布局重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36890294/

相关文章:

javascript - 单击时 HTML 字段中的文本会消失吗?

c++ - 是否可以枚举 wxWidgets 中的 wxFrame 子级?

macos - "Enter Full Screen"wxWidgets 中的热键

java - 如何合并2个链表

java - 如何在 Spring 更新时显示 &lt;input&gt; 文本字段中的属性值?

Java 逻辑运算符短路

java - 转义密码中的@字符

java - 如何调试第三方Gradle插件?

java - 在 SQLite 中使用 IN 子句

android - Jsoup - 缺少内容