Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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 当我将导航抽屉活动创建为启动器活动时,我应该在哪里设计主布局?_Android_Xml_Android Studio_Android Layout - Fatal编程技术网

Android 当我将导航抽屉活动创建为启动器活动时,我应该在哪里设计主布局?

Android 当我将导航抽屉活动创建为启动器活动时,我应该在哪里设计主布局?,android,xml,android-studio,android-layout,Android,Xml,Android Studio,Android Layout,我想在主活动中有一个导航抽屉,因此我创建了一个导航抽屉活动作为启动程序活动 我在content\u layout中设计了我的主布局,我不知道它是否正确,但当我想在底部放置退出按钮(ImageButton)时,它不工作,也不会进入页面底部,而是向左移动。 这是我的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="ver

我想在
主活动中有一个
导航抽屉
,因此我创建了一个
导航抽屉活动
作为启动程序活动

我在
content\u layout
中设计了我的
主布局
,我不知道它是否正确,但当我想在底部放置
退出按钮(ImageButton)时,它不工作,也不会进入页面底部,而是向左移动。
这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:orientation="vertical"
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/app_bar_main">
    <LinearLayout
        android:gravity="center"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:gravity="center"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <ImageButton
                android:background="@drawable/guidance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageButton>
            <ImageButton
                android:onClick="btn_about"
                android:background="@drawable/about"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"></ImageButton>
        </LinearLayout>
        <ImageButton
            android:background="@drawable/exit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"></ImageButton>
    </LinearLayout>
    <fragment
        android:id="@+id/nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:defaultNavHost="true"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/mobile_navigation"/>
</LinearLayout>

对于第二个线性布局,使用
RelativeLayout
而不是线性布局。在退出按钮内使用android:layout\u alignParentBottom=“true”
。这会将ImageButton移到左下角