android侧滑
来源:互联网 发布:三维图片制作软件 编辑:程序博客网 时间:2024/06/08 20:15
参考文献:file:///D:/android/sdk/docs/training/implementing-navigation/nav-drawer.html
使用DrawerLayout
APIs 通过Support Library :android.support.v4.app
在layout中添加布局样式:
<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"> <!-- The main content view --> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- The navigation drawer --> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="#111"/></android.support.v4.widget.DrawerLayout>
第一个布局为可显示的布局与<LinearLayout>类似,第二存放你要侧滑的内容
通过ActionBarDrawerToggle方法使用action bar来监听drawlout。
mDrawerToggle=new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close ){ public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } };;
mDrawerLayout.setDrawerListener(mDrawerToggle);
在menu中单击事件出发右侧栏mDrawerToggle.onOptionsItemSelected(item)
@Override public boolean onOptionsItemSelected(MenuItem item) { // Pass the event to ActionBarDrawerToggle, if it returns // true, then it has handled the app icon touch event if (mDrawerToggle.onOptionsItemSelected(item)) { return true; } // Handle your other action bar items... return super.onOptionsItemSelected(item); }
如果不使用action bar 侧滑通过手指右滑实现显示
getActionBar().setDisplayHomeAsUpEnabled(false); getActionBar().setHomeButtonEnabled(false);
0 0
- Android 侧滑
- android侧滑
- Android DrawerLayout 侧滑
- ANDROID drawerlayout+fragment侧滑
- android实现qq侧滑
- android--UI---侧滑drawerLayout
- android 控件 侧滑navigationview
- Android侧滑-DrawerLayout
- Android
- android
- Android
- android
- android
- Android
- Android
- android
- android
- android
- Android捕捉图像后在SurfaceView上变形显示问题的处理
- hibernate的基本使用
- 正则表达式
- 异步 同步 阻塞 非阻塞
- kafka zookeeper docker容器互联
- android侧滑
- 544. Output Contest Matches
- Ubuntu 中软件的安装、卸载以及查看的方法总结
- 微信小程序日历
- Hibernate整理学习(一)
- 移植OpenSSL加密软件到ARM
- PHP的array_keys() 函数
- WPF studying~随记
- 悟得一句真言