You can do it with the navigation box very well. Here is an example I found
MainActivity.java
package ir.ZiaNazari.navigationdrawer; import android.os.Bundle; import android.app.Activity; import android.content.res.Configuration; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { private String[] drawerListViewItems; private DrawerLayout drawerLayout; private ListView drawerListView; private ActionBarDrawerToggle actionBarDrawerToggle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
drawer_listview_item.xml
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@android:id/text1" android:textColor="#fff" android:textSize="20sp" android:gravity="center_vertical" android:paddingStart="14.5sp" android:paddingEnd="14.5sp" android:minHeight="35sp" > </TextView>
activity_main.xml
<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" android:background="@drawable/myshape" > <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choiceMode="singleChoice" android:divider="#666" android:dividerHeight="1dp" android:background="#333" android:paddingLeft="15sp" android:paddingRight="15sp" /> </android.support.v4.widget.DrawerLayout>
string.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Navigation Drawer</string> <string name="action_settings">Settings</string> <string name="hello_world">Hello world!</string> <string-array name="items"> <item>Item 1</item> <item>Item 2</item> <item>Item 3</item> <item>Item 4</item> <item>Item 5</item> <item>Item 6</item> </string-array> <string name="drawer_open">Open navigation drawer</string> <string name="drawer_close">Close navigation drawer</string> </resources>
Hope this helps you and other people.
source share