我已经在 Material Calculator 应用程序、Google Play 以及现在的 BottomNavigation 视图上看到了这种波纹颜色效果。
如何从触摸开始制作这种颜色效果?
我已经在 Material Calculator 应用程序、Google Play 以及现在的 BottomNavigation 视图上看到了这种波纹颜色效果。
如何从触摸开始制作这种颜色效果?
我认为如果您使用样式会更容易:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlHighlight">@color/ripple_material_dark</item>
</style>
如果您知道如何制作简单的波纹,那么这里是更改颜色的代码:
RippleDrawable rippleDrawable = (RippleDrawable)view.getBackground(); // assumes bg is a RippleDrawable
int[][] states = new int[][] { new int[] { android.R.attr.state_enabled} };
int[] colors = new int[] { Color.BLUE }; // sets the ripple color to blue
ColorStateList colorStateList = new ColorStateList(states, colors);
rippleDrawable.setColor(colorStateList);
两个答案都有效,但我找到了一个库,可以在使用 BottomNavigation 时简化工作: