0

我試過使用谷歌搜索的圖片之一,但我想知道是否有一種方法可以指定在佈局文件中使用十六進制的浮動操作按鈕的顏色。 我希望顏色與應用程序的其他部分有關。我在哪裏可以找到android studio中浮動動作按鈕的圖標?

+0

搜索圖標的最佳位置是:[materialdesignicons.com](https://materialdesignicons.com/)和[google設計圖標](https://design.google.com/icons/index.html) –

回答

0

您可以通過app:backgroundTint屬性在FloatingActionButton XML改變FAB的顏色

<android.support.design.widget.FloatingActionButton 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/ic_myicon" 
app:backgroundTint="@color/mycolor" 
app:fabSize="normal" 
app:elevation="5dp"> 
+0

這將工作與圖像我得到谷歌?我的drawables目錄中沒有FAB圖標。 –

+0

是的,它會工作完美,但一定要使用PNG圖像的圖標 – deejay

0

您可以使用syles.xml colorAccent浴液操作按鈕顏色:

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
    <item name="drawerArrowStyle">@style/drawer_toggle</item> 
</style> 

,或者如果你不」要想改變colorAccent,你可以使用backgroundTint,就像deejay所說的那樣。

+0

這將工作,如果我從谷歌下載圖像,並把它放在我的drawables目錄?我的drawables目錄沒有帶有浮動操作按鈕圖標 –

相關問題