修改Android FloatingActionButton的title的文字顏色及背景顏色實(shí)例詳解
修改Android FloatingActionButton的title的文字顏色及背景顏色實(shí)例詳解
首先看一張圖片

我是在一個(gè)不錯(cuò)的開源的FloatingActionButton庫基礎(chǔ)上實(shí)現(xiàn)的,鏈接github開源庫 參考圖片的標(biāo)記和代碼里的注釋。代碼如下:
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/fab_meau"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
fab:fab_addButtonColorNormal="@color/theme_color" //修改meau按鈕的背景色
fab:fab_addButtonColorPressed="@color/fab_pressed_color" //meau按鈕按下的顏色
fab:fab_addButtonPlusIconColor="@color/white" //meau中間 "+" 的顏色
fab:fab_labelStyle="@style/fab_labels_style" //title樣式,可以修改title的顏色和背景
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_action_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_title="聯(lián)系客服發(fā)布信息" //button的標(biāo)題
fab:fab_size="mini" //normal和mini兩個(gè)值,normal和meau一樣大
/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_action_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_title="個(gè)人發(fā)布信息"
fab:fab_size="mini"
fab:fab_colorPressed="@color/fab_pressed_color"
/>
</com.getbase.floatingactionbutton.FloatingActionsMenu>
在value.xml配置樣式fab_labels_style代碼如下:
<style name="fab_labels_style">
<item name="android:background">@drawable/fab_label_background</item> //文字背景的樣式
<item name="android:textColor">@color/black</item> //文字的顏色
</style>
drawable文件夾下的fab_label_background.xml代碼如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"/>
<padding
android:left="16dp"
android:top="4dp"
android:right="16dp"
android:bottom="4dp"/> //離內(nèi)邊框的距離
<corners
android:radius="5dp"/> //邊框四個(gè)叫的弧度
<stroke
android:width="1dp"
android:color="@color/text_color_84"/> //邊框邊線的寬度和顏色
</shape>
搜了網(wǎng)上修改FloatingActionButton的title顏色,結(jié)果沒有搜到,解決了問題后總結(jié)一下。
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Android如何獲取子View的位置及坐標(biāo)詳解
這篇文章主要給大家介紹了關(guān)于Android如何獲取子View的位置及坐標(biāo)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10
Android?registerForActivityResult新用法實(shí)現(xiàn)兩個(gè)Activity間數(shù)據(jù)傳遞
這篇文章主要為大家介紹了Android?registerForActivityResult新用法實(shí)現(xiàn)兩個(gè)Activity間數(shù)據(jù)傳遞詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-04-04
Android WebView如何判定網(wǎng)頁加載的錯(cuò)誤
這篇文章主要介紹了Android WebView如何判定網(wǎng)頁加載的錯(cuò)誤,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2021-04-04
Android studio報(bào): java.lang.ExceptionInInitializerError 錯(cuò)誤
本篇文章主要介紹了Android studio報(bào): java.lang.ExceptionInInitializerError錯(cuò)誤的解決方法,具有很好的參考價(jià)值。下面跟著小編一起來看下吧2017-03-03
Android編程自定義菜單實(shí)現(xiàn)方法詳解
這篇文章主要介紹了Android編程自定義菜單實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了Android自定義菜單的布局、動畫及功能相關(guān)實(shí)現(xiàn)技巧與注意事項(xiàng),需要的朋友可以參考下2017-02-02
Android 應(yīng)用適配 Android 7.0 權(quán)限要求詳解
今天小編就為大家分享一篇Android 應(yīng)用適配 Android 7.0 權(quán)限要求詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08

