一直试图改变材质的浮动动作按钮颜色,但没有成功.
<android.support.design.widget.FloatingActionButton
android:id="@+id/profile_edit_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:clickable="true"
android:src="@drawable/ic_mode_edit_white_24dp" />
Run Code Online (Sandbox Code Playgroud)
我试过补充一下
android:background="@color/mycolor"
Run Code Online (Sandbox Code Playgroud)
或通过代码
FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.profile_edit_fab);
fab.setBackgroundColor(Color.parseColor("#mycolor"));
Run Code Online (Sandbox Code Playgroud)
要么
fab.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#mycolor")));
Run Code Online (Sandbox Code Playgroud)
但以上都没有奏效.我也在"重复的问题"中尝试了解决方案,但它们都没有工作,按钮保持绿色并且也变成了正方形.
我想详细解答一下,谢谢.
PS知道如何添加涟漪效果也不错,也无法理解.
如何在运行时更改活动中的FAB图标.我有这个代码 - >
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fabMainActivity);
Run Code Online (Sandbox Code Playgroud)
我知道这是可能的使用,fab.setBackgroundDrawable();
但我是Android的新手,不明白该怎么做.
任何帮助将受到高度赞赏.
谢谢
我正在使用浮动操作按钮,我想更改背景颜色.
这是我的代码
<android.support.design.widget.FloatingActionButton
android:id="@+id/btnfab"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:layout_marginBottom="20dp"
android:src="@drawable/search" />
Run Code Online (Sandbox Code Playgroud)
这是我用来尝试实现此目的的代码:
1- android:background="@color/mycolor"
2- android:backgroundTint="@color/white"
Run Code Online (Sandbox Code Playgroud)
如图所示,我也在我的FAB上找到了一个角落.我该如何删除那些角落阴影?