Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Studio:布局在设备按钮下_Android_User Interface_Navigation - Fatal编程技术网

Android Studio:布局在设备按钮下

Android Studio:布局在设备按钮下,android,user-interface,navigation,Android,User Interface,Navigation,我正在编写一个android应用程序,用户界面有问题 我有一个聊天区,在这里有样式: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:b

我正在编写一个android应用程序,用户界面有问题

我有一个聊天区,在这里有样式:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#efefef"
android:orientation="vertical"
tools:context=".FragmentChat"
android:id="@+id/chat_layout"
android:layout_alignParentStart="true"
>

<ListView
    android:id="@+id/messages"
    android:layout_width="match_parent"
    android:layout_height = "fill_parent"
    android:height = "0dp"
    android:stackFromBottom="true"
    android:transcriptMode="alwaysScroll"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:layout_above="@+id/linearLayout" />
    <!--
    android:background="@null"
    android:divider="@null"
    -->


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="5"
        android:id="@+id/linearLayout"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true">

    <EditText
        android:id="@+id/message"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="4" />

    <Button
        android:id="@+id/send"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="Send" />

    </LinearLayout>
</RelativeLayout>

但是,;当我尝试在模拟器中运行应用程序时,视图的底部会延伸到导航按钮下

然而,我希望它是这样的:

,如Android Studio的布局预览部分所示

我尝试了多次迭代,对布局的每个成员使用不同的
layout\u height
值,即使预览显示正确,但实际运行时,编辑视图和按钮仍保留在导航按钮下。你能帮我解决这个问题吗


编辑:我找到了问题所在。由于视图是选项卡式的,
layout\u height=“match\u parent”
将编辑文本和按钮放置在最高选项卡片段的最低点。但仍然无法找到解决方案。


<?xml version="1.0" encoding="utf-8"?>

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

    <ListView
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        />

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

        <EditText
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />

    </LinearLayout>
</LinearLayout>


只需使用根目录的基本框架布局,而不是RelativeLayout。然后在列表中设置一个静态marginBottom。同时为线性布局制作重力底部。由于动态高度,ListView不是ui关系的可靠组件。在您的代码中,ListView正在覆盖您的LinearLayout。请从ListView中删除android:stackFromBottom=“true”。这两种方法都无法解决问题。由于视图是选项卡式的,
layout\u height=“match\u parent”
将编辑文本和按钮放置在最高选项卡片段的最低点。但仍然找不到解决方案。只需使用根目录的基本框架布局,而不是RelativeLayout。然后在列表中设置一个静态marginBottom。同时为线性布局制作重力底部。由于动态高度,ListView不是ui关系的可靠组件。在您的代码中,ListView正在覆盖您的LinearLayout。请从ListView中删除android:stackFromBottom=“true”。这两种方法都无法解决问题。由于视图是选项卡式的,
layout\u height=“match\u parent”
将编辑文本和按钮放置在最高选项卡片段的最低点。但仍然找不到解决方案。我找到了问题所在。由于视图是选项卡式的,
layout\u height=“match\u parent”
将编辑文本和按钮放置在最高选项卡片段的最低点。但仍然找不到解决方案。我找到了问题所在。由于视图是选项卡式的,
layout\u height=“match\u parent”
将编辑文本和按钮放置在最高选项卡片段的最低点。但仍然无法找到解决方案。