修改Android FloatingActionButton的title的文字顏色及背景顏色實(shí)例詳解
修改Android FloatingActionButton的title的文字顏色及背景顏色實(shí)例詳解
首先看一張圖片
我是在一個不錯的開源的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兩個值,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="個人發(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"/> //邊框四個叫的弧度 <stroke android:width="1dp" android:color="@color/text_color_84"/> //邊框邊線的寬度和顏色 </shape>
搜了網(wǎng)上修改FloatingActionButton的title顏色,結(jié)果沒有搜到,解決了問題后總結(jié)一下。
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Android將圖片上傳到php服務(wù)器的實(shí)例代碼
這篇文章主要介紹了Android將圖片上傳到php服務(wù)器的實(shí)例代碼,需要的朋友可以參考下2017-07-07Android編程實(shí)現(xiàn)禁止StatusBar下拉的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)禁止StatusBar下拉的方法,涉及Android StatusBarManager相關(guān)屬性控制操作技巧,需要的朋友可以參考下2017-08-08Android編程實(shí)現(xiàn)PendingIntent控制多個鬧鐘的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)PendingIntent控制多個鬧鐘的方法,涉及PendingIntent屬性設(shè)置與使用的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-12-12Android實(shí)現(xiàn)手勢滑動多點(diǎn)觸摸縮放平移圖片效果(二)
這篇文章主要介紹了Android實(shí)現(xiàn)手勢滑動多點(diǎn)觸摸縮放平移圖片效果,實(shí)現(xiàn)圖片支持多點(diǎn)觸控,自由的進(jìn)行縮放、平移的注意事項(xiàng),感興趣的小伙伴們可以參考一下2016-02-02Android使用IntentService進(jìn)行apk更新示例代碼
這篇文章主要介紹了Android使用IntentService進(jìn)行apk更新示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-01-01Android學(xué)習(xí)之使用SharedPreferences存儲應(yīng)用程序數(shù)據(jù)
這篇文章主要為大家詳細(xì)介紹了Android學(xué)習(xí)之使用SharedPreferences保存應(yīng)用程序數(shù)據(jù)的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05Android中可以作為Log開關(guān)的一些操作及安全性詳解
Android的調(diào)試好伙伴Log在調(diào)試時非常有用,基本可以看Log而無需單點(diǎn)調(diào)試,尤其對實(shí)時大數(shù)據(jù)量的設(shè)備調(diào)試尤其有效,下面這篇文章就來給大家詳細(xì)介紹關(guān)于Android中可以作為Log開關(guān)的一些操作及安全性的相關(guān)資料,需要的朋友可以參考下。2017-12-12Android實(shí)現(xiàn)雷達(dá)View效果的示例代碼
這篇文章主要介紹了Android實(shí)現(xiàn)雷達(dá)View效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06學(xué)習(xí)使用Material Design控件(四)Android實(shí)現(xiàn)標(biāo)題欄自動縮放、放大效果
這篇文章主要為大家介紹了學(xué)習(xí)使用Material Design控件的詳細(xì)教程,Android實(shí)現(xiàn)標(biāo)題欄自動縮放、放大效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07Android開發(fā)筆記之Android中數(shù)據(jù)的存儲方式(二)
我們在實(shí)際開發(fā)中,有的時候需要儲存或者備份比較復(fù)雜的數(shù)據(jù)。這些數(shù)據(jù)的特點(diǎn)是,內(nèi)容多、結(jié)構(gòu)大,比如短信備份等,通過本文給大家介紹Android開發(fā)筆記之Android中數(shù)據(jù)的存儲方式(二),對android數(shù)據(jù)存儲方式相關(guān)知識感興趣的朋友一起學(xué)習(xí)吧2016-01-01