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

來源:互聯網
上載者:User

標籤:android   material design   

官網地址:https://developer.android.com/intl/zh-tw/training/material/get-started.html

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>
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的變化可在響應觸摸手勢時可能是有用的。

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將被啟用


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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.