I have implemented navigation drawer in my application. I want this navigation drawer to display just like google play i.e it will overlay action bar. I googled it but have not find any perfect solution. Since I already implemented a navigation drawer so I don't want to implement overlay-ed android navigation drawer. Is there any way I can turn my navigation drawer into an overlay-ed one. I was trying to change application theme to no action bar in my onDeawerOpen()
, but it was not work for me. Any body have any simple idea for this. Or I have to implement a overlay-ed navigation drawer? Here is the code of my MainClass
.
public class Activity_Home extends Activity {
private String[] titles;
private DrawerLayout drawerLayout;
private ListView drawerList;
private ArrayList<Model_Drawer_Items> drawerItems;
private TypedArray drawerIcons;
Adpater_DrawerAdapter drawerAdapter;
private ActionBarDrawerToggle actionBarDrawerToggle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.drawer_main);
setupDrawer();
ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(true);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.back, R.string.app_name, R.string.app_name
) {
public void onDrawerClosed(View view) {
}
public void onDrawerOpened(View drawerView) {
// setTheme(R.style.noActionBarTheme);
}
};
drawerLayout.setDrawerListener(actionBarDrawerToggle);
drawerList.setOnItemClickListener(new DrawerItemClickListener());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity__main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
}
return super.onOptionsItemSelected(item);
// }
}
public void setupDrawer() {
try {
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerList = (ListView) findViewById(R.id.drawer_list);
View header = getLayoutInflater().inflate(R.layout.drawer_header, null);
drawerList.addHeaderView(header);
drawerIcons = getResources().obtainTypedArray(R.array.navigation_iconos);
titles = getResources().getStringArray(R.array.nav_options);
drawerItems = new ArrayList<Model_Drawer_Items>();
drawerItems.add(new Model_Drawer_Items(titles[0], drawerIcons.getResourceId(0, -1)));
drawerItems.add(new Model_Drawer_Items(titles[1], drawerIcons.getResourceId(1, -1)));
drawerItems.add(new Model_Drawer_Items(titles[2], drawerIcons.getResourceId(2, -1)));
drawerItems.add(new Model_Drawer_Items(titles[3], drawerIcons.getResourceId(3, -1)));
drawerItems.add(new Model_Drawer_Items(titles[4], drawerIcons.getResourceId(4, -1)));
drawerItems.add(new Model_Drawer_Items(titles[5], drawerIcons.getResourceId(5, -1)));
drawerItems.add(new Model_Drawer_Items(titles[6], drawerIcons.getResourceId(6, -1)));
drawerItems.add(new Model_Drawer_Items(titles[7], drawerIcons.getResourceId(6, -1)));
drawerItems.add(new Model_Drawer_Items(titles[8], drawerIcons.getResourceId(6, -1)));
drawerItems.add(new Model_Drawer_Items(titles[9], drawerIcons.getResourceId(6, -1)));
drawerItems.add(new Model_Drawer_Items(titles[10], drawerIcons.getResourceId(6, -1)));
drawerAdapter = new Adpater_DrawerAdapter(this, drawerItems);
drawerList.setAdapter(drawerAdapter);
} catch (NotFoundException e) {
e.printStackTrace();
}
}
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
}
private void selectItem(int position) {
switch (position) {
default:
break;
}
}
}
}
My drawer is working perfectly. Just want an overlay-ed one.Thanks in advance. And one more thing. Does overlay-ed drawer worked only on 4.0 and above?