Android Sliding Menu with WebView
http://www.viralandroid.com/2015/09/android-sliding-menu-with-webview.html
In this tutorial, I’m going to show how to make android sliding menu with WebView. Android WebView is a View that displays any website to your android application. You can also find many android navigation drawer view libraries in the internet and you can find many android WebView tutorials at Android WebView Tutorial with Example.
Related:
Best Navigation Drawer Libraries for Android Project
Navigation Drawer View User Interface (UI) Design for Android
Android Navigation Drawer View: Material Design Support Library
Let’s start by creating a new android project to make Android Sliding Menu with WebView with the following information.
Application Name: Sliding Menu
Company Domain: viralandroid.com
Package Name: com.viralandroid.slidingmenu
Minimum SDK: Android 2.2 (API 8 Froyo)
Add design support library dependency in your build.gradle file which looks like this.
Add colorPrimary, colorPrimaryDark and change your app theme. The final code of your styles.xml file looks like this.
res/values/styles.xml
And also create colors.xml file in your value directory and add following colors.
res/valuers/colors.xml
To add menu items, you have to create navigation_items.xml file in your menu directory.
res/menu/navigation_items.xml
And also add following strings in your strings.xml file.
res/values/strings.xml
Following is the final code of your activity_main.xml file.
res/layout/activity_main.xml
Your MainActivity.java file looks like this.
src/MainActivity.java
After Creating ViralAndroidActivity.java and GoogleActivity.java file, add following code.
src/ViralAndroidActivity.java
src/GoogleActivity.java
Following is the final xml code of viral_android.xml and google.xml file.
res/layout/viral_android.xml
res/google.xml
You have to add internet permission in AndroidManifest.xml file of your application.
And default code of menu_main.xml file looks like this.
res/menu/menu_main.xml
Don’t forget to add sliding menu icon in your drawable folder.
res/drawable/google.png
res/drawable/ic_launcher.png
res/drawable/viral_android.png
That’s it. Now, run your Sliding Menu with WebView application.
Best Navigation Drawer Libraries for Android Project
Navigation Drawer View User Interface (UI) Design for Android
Android Navigation Drawer View: Material Design Support Library
Android Sliding Menu with WebView Demo
Create a new Android Project
Let’s start by creating a new android project to make Android Sliding Menu with WebView with the following information.
Application Name: Sliding Menu
Company Domain: viralandroid.com
Package Name: com.viralandroid.slidingmenu
Minimum SDK: Android 2.2 (API 8 Froyo)
Add Design Support Library Dependency
Add design support library dependency in your build.gradle file which looks like this.
Modify your styles.xml file
Add colorPrimary, colorPrimaryDark and change your app theme. The final code of your styles.xml file looks like this.
res/values/styles.xml
And also create colors.xml file in your value directory and add following colors.
res/valuers/colors.xml
Adding Menu Items
To add menu items, you have to create navigation_items.xml file in your menu directory.
res/menu/navigation_items.xml
And also add following strings in your strings.xml file.
res/values/strings.xml
Adding DrawerLayout and NavigationView in your XML Activity Layout File
Following is the final code of your activity_main.xml file.
res/layout/activity_main.xml
MainActivity.java File
Your MainActivity.java file looks like this.
src/MainActivity.java
Create ViralAndroidActivity.java and GoogleActivity.java File
After Creating ViralAndroidActivity.java and GoogleActivity.java file, add following code.
src/ViralAndroidActivity.java
src/GoogleActivity.java
Create viral_android.xml and google.xml File
Following is the final xml code of viral_android.xml and google.xml file.
res/layout/viral_android.xml
res/google.xml
Add Internet Permission in AndroidManifest.xml File
You have to add internet permission in AndroidManifest.xml file of your application.
Following is the final modified code of AndroidManifest.xml file.
And default code of menu_main.xml file looks like this.
res/menu/menu_main.xml
Don’t forget to add sliding menu icon in your drawable folder.
res/drawable/google.png
res/drawable/ic_launcher.png
res/drawable/viral_android.png
That’s it. Now, run your Sliding Menu with WebView application.