2017-07-03 41 views
1

這裏有一個簡單的FloatingActionButton顯示一個浮動按鈕並設置一個標題「fab:fab_title」。我想改變這個 fab:fab_title的顏色。如何更改fab:tit_title顏色的FloatingActionButton android

<com.getbase.floatingactionbutton.FloatingActionButton 
     android:id="@+id/btn_floating_newest" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:scaleType="center" 
     android:visibility="gone" 
     fab:fab_colorNormal="@color/twitter_blue" 
     fab:fab_colorPressed="@color/twitter_blue" 
     fab:fab_icon="@mipmap/ic_launcher" 
     fab:fab_title="@string/newest" /> 

回答

1

我不是我的電腦上的權利,但我在XML文件

app:backgroundTint="#00000000" 

處理它

「」中的數字代表你的顏色 我的十六進制代碼我很確定這會起作用。

而點擊的變化你必須在編程中改變。 它與

fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("your hexadecimal color"))); 

做你必須基於把這個在您的FAB

+0

我不確定'00000000'是一個很好的例子,考慮到不透明度0 –

+0

我說的是文字顏色而不是按鈕顏色。 – InsaneCat

+0

然後在代碼中嘗試android:tint =「您的十六進制顏色」...並像另一張海報所說:嘗試另一個庫可能 Pawana

4

的OnClickListener代碼的第一行FloatingActionButton code你可能需要調用是這樣的:

myFloatingButton.findViewWithTag(R.id.fab_label).setTextColor(myNewColor); 

基本上在getLabelView()方法中做了什麼。

您也可以覆蓋該類並創建您自己的方法,以便設置顏色。 此功能也有一個pull request,但尚未合併。

無論如何,你應該尋找一個更新的圖書館,這個在2年內沒有被觸及。