在Android Studio中创建新项目时Android Studio会提示Activity。 导航抽屉活动我希望抽屉切换显示,但默认模式下它隐藏在导航下。Android Studio NavigationDrawer
这是我的代码:
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
请帮助这一变化也表明抽屉切换...
请发表您的活动代码 – Rohit5k2
这个默认的代码我的朋友...: 的setContentView(R.layout.activity_main); 工具栏工具栏=(工具栏)findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer =(DrawerLayout)findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this,drawer,toolbar,R.string.navigation_drawer_open,R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); –
看到这个http://stackoverflow.com/questions/26464326/how-do-i-make-drawerlayout-to-display-below-the-toolbar – Rohit5k2