Android 中FloatingActionButton(懸浮按鈕)實例詳解
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=""------------------邊框?qū)挾?,通常設置為0 ,用于解決Android 5.X設備上陰影無法正常顯示的問題
2、app:backgroundTint=""---------------按鈕的背景顏色,不設置,默認使用theme中colorAccent的顏色
3、app:rippleColor=""--------------------點擊的邊緣陰影顏色
4、app:elevation=""----------------------邊緣陰影的寬度
5、app:pressedTranslationZ="16dp"-----點擊按鈕時,按鈕邊緣陰影的寬度,通常設置比elevation的數(shù)值大
效果圖:
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
ListView實現(xiàn)下拉動態(tài)渲染數(shù)據(jù)
這篇文章主要為大家詳細介紹了ListView實現(xiàn)下拉動態(tài)渲染數(shù)據(jù)的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06Android 用RxBinding與RxJava2實現(xiàn)短信驗證碼倒計時功能
這篇文章主要介紹了Android 用RxBinding與RxJava2實現(xiàn)短信倒計時功能示例,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-10-10Android5.0+ CollapsingToolbarLayout使用詳解
這篇文章主要為大家詳細介紹了Android5.0+ CollapsingToolbarLayout使用,感興趣的小伙伴們可以參考一下2016-09-09