Android NavigationView

---恢复内容开始---

最近要写一个侧边栏,然后看教程说可以直接新建Activity中的NavigationViewActivity,但是点击之后,并不懂怎么改变她里面的内容。

点击之后生成了一个.Java文件

    生成了  四个layout文件,

在Java代码中先调用的是activity_slider.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     //include代表的是包含的其他文件。
        layout="@layout/app_bar_slider"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_slider"    //这里写的是侧滑栏中的头部所包含的东西,如果需要修改,可以直接在nav_header_slider文件中修改代码即可;
        app:menu="@menu/activity_slider_drawer" />    //这里写的是头部以下的内容,可以在menu文件夹下的activity_slider_drawer文件中修改所要显现的内容

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

 

posted @ 2016-12-07 17:30  璇璇TX  阅读(256)  评论(0)    收藏  举报