简体   繁体   English

FloatingActionButton不会改变颜色

[英]FloatingActionButton is not changing colour

I'm using this library which is pretty awesome for implementing floating action button with customized menu and many other stuffs. 我正在使用这个库 ,这对于实现具有自定义菜单和许多其他东西的浮动操作按钮非常棒。

But while using this library I'm facing trouble with changing the color of the FloatingActionButton inside a FloatingActionMenu . 不过,虽然使用这个库我现在面临的麻烦与改变的颜色FloatingActionButton一个内部FloatingActionMenu I tried putting fab:manu_colorNormal as a property of the FloatingActionButton , but it seems it has no effect and showing the default colour. 我尝试将fab:manu_colorNormal作为FloatingActionButton的属性,但它似乎没有效果并显示默认颜色。

Here's the layout I'm using. 这是我正在使用的布局。 Note that, I've used xmlns:fab="http://schemas.android.com/apk/res-auto" . 请注意,我使用过xmlns:fab="http://schemas.android.com/apk/res-auto" It was suggested somewhere to check if the xmlns:fab is pointed to apk/res-auto . 建议在某处检查xmlns:fab是否指向apk/res-auto I set that properly, but yet no luck. 我设置得当,但没有运气。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/background">

    <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/fab_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        fab:menu_colorNormal="@color/fab_close_background"
        fab:menu_colorPressed="@color/fab_close_background_pressed"
        fab:menu_colorRipple="@color/fab_close_background_ripple">

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/menu_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_delete_white_24dp"
            fab:fab_size="mini"
            fab:menu_colorNormal="@color/fab_delete_background"
            fab:menu_colorPressed="@color/fab_delete_background_pressed"
            fab:menu_colorRipple="@color/fab_delete_background_ripple" />

    </com.github.clans.fab.FloatingActionMenu>

</RelativeLayout>

Note: I could change the colour of the FloatingActionMenu button successfully. 注意:我可以成功更改FloatingActionMenu按钮的颜色。 menu_colorNormal works perfectly for the close button in my layout. menu_colorNormal适用于我的布局中的关闭按钮。

Here's how it looks like in my application. 这是它在我的应用程序中的样子。 Red is the default colour which I'm trying to change. 红色是我试图改变的默认颜色。 The issue is reported here in Github . 这个问题在Github报告

浮动操作菜单以及迷你按钮

Replace fab:menu_colorNormal to fab:fab_colorNormal in FloatingActionButton fab:menu_colorNormal替换为fab:fab_colorNormal in FloatingActionButton

fab:menu_colorNormal is used to set the color of menu icon and fab:fab_colorNormal is used to set the color of floating action button. fab:menu_colorNormal用于设置菜单图标和fab的颜色:fab_colorNormal用于设置浮动动作按钮的颜色。

See the doc here. 请参阅此处的文档。

Use following code: 使用以下代码:

 <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/menu_green"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginRight="150dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        fab:menu_icon="@drawable/ic_star"
        fab:menu_animationDelayPerItem="0"
        fab:menu_colorNormal="#43A047"
        fab:menu_colorPressed="#2E7D32"
        fab:menu_colorRipple="#1B5E20"
        fab:menu_labels_maxLines="2"
        fab:menu_labels_ellipsize="end">

        <com.github.clans.fab.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_edit"
            fab:fab_label="Menu item 1"
            fab:fab_colorNormal="#43A047"
            fab:fab_colorPressed="#2E7D32"
            fab:fab_colorRipple="#1B5E20" />

    </com.github.clans.fab.FloatingActionMenu>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM