2015年5月29日 星期五

Android 開發 (九十四) What's New in M support-design-widget FloatingActionButton

what's FloatingActionButton? 讓我們來看看下面的圖



值得注意的是我的版本是4.4 ,但是有shadow,而且點擊的時候也有shadow,
接下來我們要介紹如何實作,FloatingActionButton的實作方式更簡單
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:android.support.design="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:src="@drawable/abc_ic_clear_mtrl_alpha"
        android.support.design:fabSize="mini" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:src="@drawable/abc_ic_clear_mtrl_alpha"
        android.support.design:fabSize="normal" />
</LinearLayout>

只需要將ui放到xml上就完成了XD
在這邊值得一提的是,floatingActionButton有一個property fabSize,
要在xml上使用則必須加上
xmlns:android.support.design="http://schemas.android.com/apk/res-auto"
才能正確使用,fabSize有分normal and mini如上圖,就是正常size和mini size

今天介紹floatingActionButton就到這邊,接下來還會有需多新的ui會介紹唷!!

沒有留言:

張貼留言