【发布时间】:2015-09-07 06:50:28
【问题描述】:
我一直在尝试更改 Material 的 Floating Action Button 颜色,但没有成功。
<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")));
但以上都没有奏效。我也尝试了提出的重复问题中的解决方案,但它们都不起作用;按钮保持绿色,也变成了一个正方形。
附:想知道怎么添加涟漪效果也不错,也看不懂。
【问题讨论】:
-
涟漪效果在棒棒糖之前的设备上不可用,因为它使用了新的RenderThread。
-
@karaokyo 好的,但我是怎么做到的?
-
在我看来,Google 在让这些东西可以访问方面做得非常糟糕
-
要以编程方式执行此操作并向后兼容,请参阅stackoverflow.com/questions/30966222/…
标签: java android android-5.0-lollipop floating-action-button