亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

導航抽屜沒有折疊,沒有漢堡包按鈕

導航抽屜沒有折疊,沒有漢堡包按鈕

收到一只叮咚 2023-03-31 15:09:03
我的抽屜布局顯示為正?;顒?,工具欄中沒有任何按鈕,也沒有以任何方式折疊..我希望它來自右側。這是我的抽屜活動布局..    <?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:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".myDrawer"    tools:openDrawer="start">    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical">        <android.support.v7.widget.Toolbar            android:layout_width="match_parent"            android:layout_height="?attr/actionBarSize"            android:background="#000"            android:id="@+id/drawer_toolbar"            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">        </android.support.v7.widget.Toolbar>        <FrameLayout            android:id="@+id/fragment_container"            android:layout_width="match_parent"            android:layout_height="match_parent">        </FrameLayout>    </LinearLayout><android.support.design.widget.NavigationView    android:background="@color/colorPrimaryDark"    android:layout_width="100dp"    android:layout_height="match_parent"    android:foregroundGravity="left"    app:menu="@menu/drawer_menu"    app:headerLayout="@layout/nav_header"></android.support.design.widget.NavigationView></android.support.v4.widget.DrawerLayout>這是我的 nav_header.xml 布局。    <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="wrap_content"    android:layout_height="300dp"    android:padding="15dp"    android:theme="@style/ThemeOverlay.AppCompat.Dark"><ImageView    android:layout_width="100dp"    android:layout_height="200dp"    android:src="@drawable/hhh"    />
查看完整描述

1 回答

?
智慧大石

TA貢獻1946條經驗 獲得超3個贊

用下面替換您的導航視圖


<android.support.design.widget.NavigationView

        android:layout_width="wrap_content"

        android:layout_height="match_parent"

        android:layout_gravity="start"

        android:fitsSystemWindows="true"

        app:headerLayout="@layout/nav_header"

        app:menu="@menu/my_menu">

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

添加以下方法以顯示切換


public void addToggel() {

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(

                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);

        //drawer.setDrawerListener(toggle);

        drawer.addDrawerListener(toggle);

        toggle.syncState();


        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);

    }

在 string.xml 中添加以下字符串


<string name="navigation_drawer_open">open</string>

    <string name="navigation_drawer_close">close</string>

根據您的代碼更新抽屜布局 ID 和導航視圖 ID


讓我知道更多幫助


查看完整回答
反對 回復 2023-03-31
  • 1 回答
  • 0 關注
  • 121 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號