Android(Lollipop/5.0) Material Design(二) 入门指南

来源:互联网 发布:贵州中标数据网 编辑:程序博客网 时间:2024/05/21 07:55

Material Design系列

Android(Lollipop/5.0) Material Design(一) 简介

Android(Lollipop/5.0) Material Design(二) 入门指南

Android(Lollipop/5.0) Material Design(三) 使用Material主题

Android(Lollipop/5.0) Material Design(四) 创建列表和卡片

Android(Lollipop/5.0) Material Design(五) 定义阴影和裁剪View

Android(Lollipop/5.0) Material Design(六) 使用图片

Android(Lollipop/5.0) Material Design(七) 自定义动画

Android(Lollipop/5.0) Material Design(八) 保持兼容性


官网地址:https://developer.android.com/training/material/get-started.html

开始

1. 审查材料设计规范
2. 应用材料设计主题
3. 以材料设计的指导方针来创建layouts
4. 投影:指定view的 evevation 属性 
5. 使用系统组件 lists and cards
6. 自定义动画

保持向后兼容性

详见:保持兼容性


Apply the Material Theme 运用材料主题

<!-- res/values/styles.xml --><resources>  <!-- your theme inherits from the material theme -->  <style name="AppTheme" parent="android:Theme.Material">    <!-- theme customizations -->  </style></resources>

详见 使用Material主题


Design Your Layouts  设计你的布局

除了应用和自定义材料的主题,你的布局应符合材料的设计准则。当你设计你的布局,以下需要特别注意:

· 基线网格

· Keylines

· 间距

· 触摸目标尺寸

· 布局结构


Specify Elevation in Your Views  在View中指定elevation属性

View可以投下的阴影,一个View的elevation值决定了它的阴影的大小和绘制的顺序。可以设置一个视图的elevation,在布局中使用属性:android:elevation

<TextView    android:id="@+id/my_textview"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:text="@string/next"    android:background="@color/white"    android:elevation="5dp" />

新的translationz属性使您能够创建一个反映了暂时的elevation变化的动画。elevation的变化可在响应触摸手势时可能是有用的

 详见 定义阴影和裁剪View


创建 Lists and Cards

RecyclerView是一个可插入版本的列表视图,支持不同的布局类型并提供性能改进
CardView 允许您在app中显示一块块 使用一致外观的卡片
下面的代码示例演示了如何在你的布局: CardView
<android.support.v7.widget.CardView    android:id="@+id/card_view"    android:layout_width="200dp"    android:layout_height="200dp"    card_view:cardCornerRadius="3dp">    ...</android.support.v7.widget.CardView>

详见 创建 Lists and Cards


Customize Your Animations  自定义动画

可以自定义动画,如激活Activity的过渡动画和结束过渡动画

public class MyActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        // enable transitions        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);        setContentView(R.layout.activity_my);    }    public void onSomeButtonClicked(View view) {        getWindow().setExitTransition(new Explode());        Intent intent = new Intent(this, MyOtherActivity.class);        startActivity(intent,                      ActivityOptions                          .makeSceneTransitionAnimation(this).toBundle());    }}
当你在这个Activity中启动其他的Activity时,exit transition将被激活

详见 使用自定义动画


0 0
原创粉丝点击