FloatingActionButton(懸浮按鈕),floatingactionbutton
一、介紹
這個類是繼承自ImageView的,所以對於這個控制項我們可以使用ImageView的所有屬性
二、使用準備, 在as 的 build.grade檔案中寫上
compile 'com.android.support:design:22.2.0'
三、使用說明
<android.support.design.widget.FloatingActionButton android:id="@+id/floatingActionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@mipmap/ok" app:borderWidth="0dp" app:backgroundTint="#FF4011" app:rippleColor="#33728dff" app:elevation="8dp" app:pressedTranslationZ="16dp" />
可以看到我們使用了app屬性,則需要在根容器中添加這個屬性。
xmlns:app="http://schemas.android.com/apk/res-auto"
屬性介紹:
1、app:borderWidth=""------------------邊框寬度,通常設定為0 ,用於解決Android 5.X裝置上陰影無法正常顯示的問題
2、app:backgroundTint=""---------------按鈕的背景顏色,不設定,預設使用theme中colorAccent的顏色
3、app:rippleColor=""--------------------點擊的邊緣陰影顏色
4、app:elevation=""----------------------邊緣陰影的寬度
5、app:pressedTranslationZ="16dp"-----點擊按鈕時,按鈕邊緣陰影的寬度,通常設定比elevation的數值大
: