后台布局不适用于导航抽屉

时间:2019-01-13 19:46:10

标签: android-layout

我在“活动”中使用“浮动”图标,我也想在该活动中使用“导航抽屉”,但是当我使用它时,我的背景布局无法正常工作。当我将其放入代码中时,我的图标显示在菜单列表中。请帮我该怎么办。我正在使用约束布局,但此处未显示...

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:floatingMenuActionButton="http://schemas.android.com/tools"
android:id="@+id/pai"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="#FFFFFF">



<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <android.support.design.widget.NavigationView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        app:menu="@menu/navigation_menu"

        android:layout_gravity="start"
        app:headerLayout="@layout/nav_header"
        android:id="@+id/nv">

    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>

<android.support.constraint.Guideline
    android:id="@+id/gl_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="1.0"/>

<android.support.constraint.Guideline
    android:id="@+id/gl_2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="1.0"/>

<rjsv.floatingmenu.floatingmenubutton.FloatingMenuButton
    android:id="@+id/fab_1"
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginTop="52dp"
    android:scaleType="centerInside"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    floatingMenuActionButton:dispositionEndAngle="360"
    floatingMenuActionButton:dispositionStartAngle="0"
    floatingMenuActionButton:subActionButtonRadius="200"
    android:layout_marginBottom="8dp"
    android:background="@drawable/poultary"
    app:layout_constraintBottom_toTopOf="@+id/gl_1">

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_2"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_3"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_4"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_5"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_6"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_7"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_8"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />


</rjsv.floatingmenu.floatingmenubutton.FloatingMenuButton>

->

1 个答案:

答案 0 :(得分:0)

您应将主布局设为抽屉,然后在其中包含约束布局

main_activity.xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.DrawerLayout 
    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/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

        <include
            layout="@layout/your_constraint_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
        <android.support.design.widget.NavigationView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white"
            app:menu="@menu/navigation_menu"

            android:layout_gravity="start"
            app:headerLayout="@layout/nav_header"
            android:id="@+id/nv">

        </android.support.design.widget.NavigationView>

    </android.support.v4.widget.DrawerLayout>

your_constraint_layout

<?xml version="1.0" encoding="utf-8"?>
 <android.support.constraint.ConstraintLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 xmlns:floatingMenuActionButton="http://schemas.android.com/tools"
 android:id="@+id/pai"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_gravity="center_vertical"
 android:background="#FFFFFF">


<android.support.constraint.Guideline
    android:id="@+id/gl_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="1.0" />

<android.support.constraint.Guideline
    android:id="@+id/gl_2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="1.0" />

<rjsv.floatingmenu.floatingmenubutton.FloatingMenuButton
    android:id="@+id/fab_1"
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:layout_marginRight="32dp"
    android:layout_marginBottom="32dp"
    android:background="@drawable/poultary"
    android:scaleType="centerInside"
    app:layout_constraintBottom_toTopOf="@+id/gl_1"
    app:layout_constraintRight_toRightOf="parent"
    floatingMenuActionButton:dispositionEndAngle="360"
    floatingMenuActionButton:dispositionStartAngle="0"
    floatingMenuActionButton:subActionButtonRadius="200">

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_2"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_3"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_4"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_5"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_6"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_7"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />

    <rjsv.floatingmenu.floatingmenubutton.subbutton.FloatingSubButton
        android:id="@+id/fab_1_sub_fab_left_8"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/poultary" />


</rjsv.floatingmenu.floatingmenubutton.FloatingMenuButton>