嗨,大家好,我是android的新手,我刚刚开始学习android.so,我在应用中实现了导航抽屉,但是在导航抽屉中我已经使用menu.xml添加了菜单
you can always create your custom layout instead of using menu so you can design it in your way for your navigation drawer. for example.
Navigation View
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<include layout="@layout/lay_drawer_menu" />
</LinearLayout>
</ScrollView>
</android.support.design.widget.NavigationView>
lay_drawer_menu.xml
<TextView
android:id="@+id/txt1"
android:textcolor = "whatever you want"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Activities" />
<TextView
android:id="@+id/txt2"
android:textcolor = "whatever you want"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Add Detail"
android:textColor="@android:color/black" />
Activity
@Override public void onClick(View view) {
switch (view.getId()) {
case R.id.txt1: {
drawerLayout.closeDrawers();
//your code.
}
break;
case R.id.txt2: {
drawerLayout.closeDrawers();
//your code.
}
break;
}
}
hope this will help.
Well, you can go through below link to create a custom Navigation Drawer on your own.You can customize it to what ever you want. Custom Navigation Drawer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.