一直试图改变材质的浮动动作按钮颜色,但没有成功.
<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知道如何添加涟漪效果也不错,也无法理解.