這篇文章將為大家詳細講解有關FloatingActionButton如何在Android 中使用,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。
Android 中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的數值大
關于FloatingActionButton如何在Android 中使用就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。