gpt4 book ai didi

android - FloatingActionButton 没有改变颜色

转载 作者:行者123 更新时间:2023-11-29 17:18:06 25 4
gpt4 key购买 nike

我正在使用 this library这对于实现带有自定义菜单和许多其他内容的 float 操作按钮来说非常棒。

但是在使用这个库时,我遇到了更改 FloatingActionMenu 中的 FloatingActionButton 颜色的问题。我尝试将 fab:manu_colorNormal 作为 FloatingActionButton 的属性,但它似乎没有效果并显示默认颜色。

这是我正在使用的布局。请注意,我使用了 xmlns:fab="http://schemas.android.com/apk/res-auto"。有人建议在某处检查 xmlns:fab 是否指向 apk/res-auto。我设置正确,但还是不行。

<?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>

注意:我可以成功更改 FloatingActionMenu 按钮的颜色。 menu_colorNormal 非常适合我布局中的关闭按钮。

这是它在我的应用程序中的样子。红色是我要更改的默认颜色。问题是 reported here in Github .

Floating action menu along with mini buttons

最佳答案

FloatingActionButton 中的 fab:menu_colorNormal 替换为 fab:fab_colorNormal

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.

See the doc here.

使用以下代码:

 <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>

关于android - FloatingActionButton 没有改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37908172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com