我一直在尝试更改 Material 的浮动操作按钮颜色,但没有成功。
<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" />
我尝试添加:
android:background="@color/mycolor"
或通过代码:
FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.profile_edit_fab);
fab.setBackgroundColor(Color.parseColor("#mycolor"));
或者fab.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#mycolor")));
但是上述方法都没有奏效。我还尝试了提出的重复问题中的解决方案,但它们都无法正常工作;该按钮仍然保持绿色,并且变成了一个正方形。
另外,知道如何添加涟漪效果也会很好,但我也没搞懂怎么做。