Is there a way to configure only one time the Navigation Drawer, and the display it on multiple Activites?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
For this just create a BaseActivity class that implements the drawer, and let all your other activities extend this one.
For people wanting an code example with Activities, take a look at my answer over here: https://stackoverflow.com/a/19451842/2767703
If you want a nice transition I would suggest this: When you click on an item in the
NavigationDrawer
close the navigation drawer and simultaneously use postdelayed with 250 (time it takes to close theNavigationDrawer
). Also simultaneously animate the main content's alpha to 0 with 150 milliseconds. Then when an Activity starts animate the main content's alpha to 1 with 250 milliseconds. This gives a great transition. I found it in the Google IO code: https://github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/BaseActivity.javaBy the way, you should also look at the link @Harish Godara gave: http://www.michenux.net/android-navigation-drawer-748.html It works with Fragments but it has a nice way of implementing the
NavigationDrawer
.Edit
Since some links are dead here is what I used in my last project to get the animation. It is in Kotlin, but it should make the point clear. This is all code from the BaseDrawerActivity:
-
-
-
-
-