0

我已经在 Material Calculator 应用程序、Google Play 以及现在的 BottomNavigation 视图上看到了这种波纹颜色效果。

如何从触摸开始制作这种颜色效果?

GIF:https ://d13yacurqjgara.cloudfront.net/users/72535/screenshots/2673294/bottom_navigation_material_design_by_jardson_almeida.gif

在此处输入图像描述

4

3 回答 3

2

我认为如果您使用样式会更容易:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <item name="colorControlHighlight">@color/ripple_material_dark</item>
</style>
于 2016-12-01T20:31:07.457 回答
1

如果您知道如何制作简单的波纹,那么这里是更改颜色的代码:

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);
于 2016-12-01T20:26:46.037 回答
0

两个答案都有效,但我找到了一个库,可以在使用 BottomNavigation 时简化工作:

https://github.com/roughike/BottomBar

于 2016-12-01T20:59:30.177 回答