android material design 相关使用指导
2015-12-27 16:04
639 查看
来源:https://guides.codepath.com/android/Design-Support-Library#features
design support library, which helps bring a lot of
material design components including a navigation drawer view, floating labels, floating action buttons, snackbars, and a new framework to tie motion and scroll events. The library is supported for Android version 2.1 and higher.
(总结就是在2015年谷歌宣布了开发支持库Material Design,库里包含很多新的特性和控件,支持android版本最低2.1)
FloatingActionButton - A round button at the bottom right denoting a primary action on your interface. Promoting key actions within a modern
material design app.
TabLayout - An easier way to put tabs around a
NavigationView - An easier way to provide a modern navigation drawer from the left with a header and a series of navigation items.
SnackBar - Shown on the bottom of the screen and contains text with an optional single action. They automatically time out after the given
time length by animating off the screen.
TextInputLayout - Float the hint above any text field as the user is entering information and/or add
a character counter.
CoordinatorLayout - Provides an additional level of control over scroll and touch events between child views.
AppBarLayout allows your toolbar and other views to react to scroll events.
CollapsingToolbarLayout extend this to allow the toolbar to collapse as the user scrolls through a view.
PercentRelativeLayout and PercentFrameLayout to enable views to occupy
percentage-based dimensions.
(关键特性:1,悬浮动态按钮2,标签布局3,导航视图4,(不好翻译,小吃栏...)快捷栏5,文本输入布局6,协调布局7,百分比布局)
There is a new support design library that must be included. This library also depends on updated versions of the
AppCompat library to be included. If you are not currently using this library, check out this
migration guide. In addition, make sure these versions have been updated.
(要有较新的gradle构建工具)
Update your root
Add these dependencies to your
If you are using the
RecyclerView,
CardView, or any other
support v7 related libraries you should also upgrade the versions. The RecyclerView for instance has features that are used with this new design support library.
annotations library, you can also explicitly add it to your Gradle file. Adding the
AppCompat or support design library implicitly adds it:
(根据需要添加依赖项)
SDK Manager and make sure to download the
If you are using any type of continuous build system and need to help automate downloading of updates to the support library, you can use
Jake Wharton's SDK Manager to download the packages for you.
sample code. For an example of the percent support library, see
this sample code.
here. For instance, if you are curious about what styles can be overridden for the different components, see this
link.
The latest source code updates for the support library are now always included since v23.1.0 in your SDK directory (i.e.
Stack Overflow article or the official
API documentation.
A
A
guide)
An
A new item animation interface for the
Custom views can be provided for
Design Support Library
Overview
At their I/O 2015 conference, Google announced a newdesign support library, which helps bring a lot of
material design components including a navigation drawer view, floating labels, floating action buttons, snackbars, and a new framework to tie motion and scroll events. The library is supported for Android version 2.1 and higher.
(总结就是在2015年谷歌宣布了开发支持库Material Design,库里包含很多新的特性和控件,支持android版本最低2.1)
Features
The support design library has the following key features:FloatingActionButton - A round button at the bottom right denoting a primary action on your interface. Promoting key actions within a modern
material design app.
TabLayout - An easier way to put tabs around a
ViewPagerwhich acts as sliding tabs between fragments within an app.
NavigationView - An easier way to provide a modern navigation drawer from the left with a header and a series of navigation items.
SnackBar - Shown on the bottom of the screen and contains text with an optional single action. They automatically time out after the given
time length by animating off the screen.
TextInputLayout - Float the hint above any text field as the user is entering information and/or add
a character counter.
CoordinatorLayout - Provides an additional level of control over scroll and touch events between child views.
AppBarLayout allows your toolbar and other views to react to scroll events.
CollapsingToolbarLayout extend this to allow the toolbar to collapse as the user scrolls through a view.
PercentRelativeLayout and PercentFrameLayout to enable views to occupy
percentage-based dimensions.
(关键特性:1,悬浮动态按钮2,标签布局3,导航视图4,(不好翻译,小吃栏...)快捷栏5,文本输入布局6,协调布局7,百分比布局)
Setup
Make sure that you have at least the Android Gradle plugin v1.2.3 supported:dependencies { classpath 'com.android.tools.build:gradle:1.3.1' }
There is a new support design library that must be included. This library also depends on updated versions of the
AppCompat library to be included. If you are not currently using this library, check out this
migration guide. In addition, make sure these versions have been updated.
(要有较新的gradle构建工具)
Update your root
build.gradlefile
android { compileSdkVersion 23 // needs to be consistent with major support libs used } ext { supportLibVersion = '23.1.1' // variable that can be referenced to keep support libs consistent }
Add these dependencies to your
app/build.gradlefile:
dependencies { compile "com.android.support:appcompat-v7:${supportLibVersion}" compile "com.android.support:design:${supportLibVersion}" }
If you are using the
RecyclerView,
CardView, or any other
support v7 related libraries you should also upgrade the versions. The RecyclerView for instance has features that are used with this new design support library.
dependencies { compile "com.android.support:recyclerview-v7:${supportLibVersion}" }
Adding Percent Support Library
To add the percent support library, you need to add this statement:dependencies { compile "com.android.support:percent:${supportLibVersion}" }
Adding Annotations Library
To leverage theannotations library, you can also explicitly add it to your Gradle file. Adding the
AppCompat or support design library implicitly adds it:
dependencies { compile "com.android.support:support-annotations:${supportLibVersion}" }
(根据需要添加依赖项)
Installing the Library
You normally need to open theSDK Manager and make sure to download the
Android Support Repositoryas well as the latest
Android Support Library. However, Android Studio will also show at the bottom any missing libraries and you can click on the
Install repository and sync project. The process will only succeed if you specify a valid library and version, but it enables you to upgrade without needing to open the SDK Manager.
If you are using any type of continuous build system and need to help automate downloading of updates to the support library, you can use
Jake Wharton's SDK Manager to download the packages for you.
Sample Code
If you want to see how to use the various components, check out thissample code. For an example of the percent support library, see
this sample code.
Official Source Code
The Android Open Source Project (AOSP) hosts the major release versions for this library, which can be foundhere. For instance, if you are curious about what styles can be overridden for the different components, see this
link.
The latest source code updates for the support library are now always included since v23.1.0 in your SDK directory (i.e.
Library/Android/sdk/extras/android/m2repository/com/android/support/designfor Mac OS X).
Change Log
Changes in Support Library v23
Resources.getColor()has been deprecated. You must now use
ContextCompat.getColor()instead. See this
Stack Overflow article or the official
API documentation.
Changes in Support Library v23.1
TextInputLayoutand
EditTextnow includes the ability to add a character counter. (view guide)
A
snapflag can also be added to the list of scrolling effects declared in
AppBarLayout. (view guide)
A
setOnDragListener()method has been added to
App ab5c BarLayout. (view
guide)
An
aspectRatioattribute is now supported in
PercentRelativeLayout. (view guide)
A new item animation interface for the
RecyclerView. (view guide)
Custom views can be provided for
NavigationViewrows. (view guide)
Changes in Support Library v23.1.1
NavigationView now contains agetHeaderView()method (view guide)
相关文章推荐
- Android:Asynctask简单使用
- Android SDK Manager国内无法更新的解决方案
- android中gridview的上拉加载更多
- Android隐藏应用图标
- Android开发中的全屏背景显示方案
- Android控件属性方法设置
- ListView中convertview和ViewHolder的区别
- Android使用pull解析xml
- Android之数据存储共享参数简单用户登录(一)
- Android Studio开发文档doc显示问题
- android nfc中Ndef格式的读写
- 13. (转) Android一些布局属性详解
- Android混淆、反编译基础教程
- 12.Android之Tabhost组件学习
- android之Notification和PendingIntent
- 修改Android签名证书keystore的密码、别名alias以及别名密码
- Android蓝牙打印二维码打印外卖单打印
- Android - TabHost 选项卡功能用法详解
- [Android]_[初级]_[adb 实用命令]
- android 日期时间格式转换;软键盘显示消失;获取系统title