抽屉式导航栏(SlidingMenu)无法正常工作
问题描述:
我用我的活动的.xml DrawerLayout
在下面给出:抽屉式导航栏(SlidingMenu)无法正常工作
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The first child in the layout is for the main Activity UI-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#09436B"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="#F1F1F1"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/tab_selected_text_color"
app:tabTextColor="@color/tab_text_color" />
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tab_layout"></android.support.v4.view.ViewPager>
</RelativeLayout>
<!-- Side navigation drawer UI -->
<LinearLayout
android:id="@+id/layout_navigation_drawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.almabay.almachat.circularImageView.CircularImageView
android:id="@+id/imgUser"
android:layout_width="100dp"
android:layout_height="100dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtNameUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txtEmaiIDUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/margin10"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/accounts" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtNotification"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/notification" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/contacts" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtChats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/chats" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtHelp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/help" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/margin10" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/txtLogout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/logout" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
但我得到正确的导航drawer.No汉堡包图标显示
我要实现以下画面:
请指引我在哪里,我在做什么犯错误知道里面DrawerLayout一个视图是在屏幕的主要内容等是抽屉式导航items.I已经研究了各种例子,显示我必须使用导航抽屉的项目列表视图但我必须解决我的设计,我不能在这里使用列表视图。
答
我会建议你使用的导航视图(把它放在抽屉布局的底部),然后把你的项目在里面。
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start">
<include layout="@layout/your navigation view layout"/>
</android.support.design.widget.NavigationView>
感谢您的帮助,它为我工作。 –