最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android開發(fā)懸浮按鈕 Floating ActionButton的實(shí)現(xiàn)方法

 更新時(shí)間:2016年09月08日 14:17:08   作者:聽著music睡  
這篇文章主要介紹了Android開發(fā)懸浮按鈕 Floating ActionButton的實(shí)現(xiàn)方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

一、介紹

這個(gè)類是繼承自ImageView的,所以對(duì)于這個(gè)控件我們可以使用ImageView的所有屬性

android.support.design.widget.FloatingActionButton 

二、使用準(zhǔn)備, 在as 的 build.grade文件中寫上

compile 'com.android.support:design:22.2.0' 

三、使用說明

xml文件中,注意藍(lán)色字體部分

<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屬性,則需要在根容器中添加這個(gè)屬性。

xmlns:app="http://schemas.android.com/apk/res-auto" 

屬性介紹:

1、app:borderWidth=""------------------邊框?qū)挾?,通常設(shè)置為0 ,用于解決Android 5.X設(shè)備上陰影無法正常顯示的問題

2、app:backgroundTint=""---------------按鈕的背景顏色,不設(shè)置,默認(rèn)使用theme中colorAccent的顏色

3、app:rippleColor=""--------------------點(diǎn)擊的邊緣陰影顏色

4、app:elevation=""----------------------邊緣陰影的寬度

5、app:pressedTranslationZ="16dp"-----點(diǎn)擊按鈕時(shí),按鈕邊緣陰影的寬度,通常設(shè)置比elevation的數(shù)值大

另外我們希望點(diǎn)擊按鈕一個(gè)顏色,正常狀態(tài)一個(gè)顏色 以提高用戶體驗(yàn),那么就是drawable文件夾中創(chuàng)建文件 floatbutton.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorNormal"></item>
<item android:state_pressed="true" android:drawable="@color/colorPressed"></item>
</selector>

然后我們?cè)O(shè)置FloatActionButton的backgroud為這個(gè)drawable文件即可,同時(shí)app:backgroundTint=""屬性也可以不再設(shè)置

<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/floatbutton"
android:src="@mipmap/ok"
app:borderWidth="0dp"
app:rippleColor="#33728dff"
app:elevation="8dp"
app:pressedTranslationZ="16dp"
/>

效果圖:

相關(guān)文章

最新評(píng)論

呈贡县| 宣恩县| 桃源县| 马关县| 无为县| 太康县| 大田县| 清丰县| 岱山县| 延吉市| 宁明县| 莲花县| 保定市| 南昌县| 临西县| 白银市| 息烽县| 行唐县| 应城市| 文安县| 大渡口区| 武隆县| 西和县| 汶上县| 收藏| 个旧市| 香格里拉县| 仁布县| 平度市| 开封市| 卓尼县| 石渠县| 苗栗县| 哈尔滨市| 湘潭县| 平利县| 漠河县| 鄄城县| 绍兴县| 舞阳县| 沈阳市|