Android(安卓)的 Material Design 初次尝试。
Android 的 Material Design 初次尝试。
抽屉导航
android.support.v4.widget.DrawerLayout 抽屉控件,他下面包含两大块,第一块为主屏幕显示的布局,第二块为抽屉布局。
tools:openDrawer="start"//在布局中可以用这个属性控制抽屉布局显示出来
可以通过以下操作对DrawerLayout进行操作:
mDrawerLayout.openDrawer(GravityCompat.START);//开启抽屉,这里的方向应该和NavigationView的layout_gravity相同mDrawerLayout.closeDrawers();//关闭抽屉
NavigationView
全类名:android.support.design.widget.NavigationView 。我们需要导入design包。
compile 'com.android.support:design:23.4.0'
在Material Design中,Navigation drawer 导航抽屉,被设计用于应用的导航菜单,作为一种可默认隐藏,通过手势或者按钮拖出来的导航菜单。
NavigationView 的典型用途就是配合 DrawerLayout 作为体重的导航菜单的内容部分。NavigationView 是一个导航菜单的框架,使用 menu 资源填充菜单数据项,可以简单快捷的实现一个风格统一的导航菜单。NavigationView有一些配置如下:
android:layout_gravity="start"//设置菜单方位,start为左边拖拽出来,end为右边拖拽出来app:headerLayout="@layout/nev_header"//设置菜单的header部分布局app:menu="@menu/drawer_actions"//设置菜单项android:fitsSystemWindows="true"
通过以上设置,就能够在主屏幕的左边拖拽出导航菜单啦。
典型的布局代码如下:
<?xml version="1.0" encoding="utf-8"?>
Toolbars
全类名:android.support.v7.widget.Toolbar
说明:
Toolbars are versatile and can be used in many different ways.
Toolbar 的使用:
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);setSupportActionBar(mToolbar);ActionBar ab = getSupportActionBar();ab.setHomeAsUpIndicator(R.drawable.ic_menu);//设置home图标是否显示ab.setDisplayHomeAsUpEnabled(true);
AppBarLayout
全类名:android.support.design.widget.AppBarLayout
说明:
The app bar, formerly known as the action bar in Android, is a special kind of toolbar that’s used for branding, navigation, search, and actions.
AppBar 即以前我们称之为的 ActionBar,是一种用来展示信息、界面导航、搜索以及其他操作的一种特殊的工具栏。
The nav icon at the left side of the app bar can be:
- A control to open a navigation drawer.
- An up arrow for navigating upward through your app’s hierarchy.
- Omitted entirely if no navigation is required from this screen.
- The title in the app bar reflects the current page. It can be an app title, page title, or a page filter.
Icons on the right side of the app bar are app-related actions. The menu icon opens the overflow menu, which contains secondary actions and menu items like help, settings, and feedback.
更多相关文章
- 对Menu Button 说再见
- 类似home的弹出菜单(SlidingDrawer)
- 底部导航栏中间凸出效果
- 实现查询地址和路线导航的代码
- 继承Activity类应该注意的问题
- Android菜单使用小结
- Android(安卓)用户界面(User Interface)
- menu.addIntentOptions 添加动态菜单详解
- Android(安卓)google VR全景图导航