【问题标题】:BottomNavigation view ripple color effectBottomNavigation 视图波纹颜色效果
【发布时间】:2016-12-02 05:00:24
【问题描述】:

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

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

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

【问题讨论】:

    标签: android user-interface bottomnavigationview


    【解决方案1】:

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

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
      <item name="colorControlHighlight">@color/ripple_material_dark</item>
    </style>
    

    【讨论】:

    • 谢谢。这实际上很神奇。我还发现了一个简化工作的库:)
    【解决方案2】:

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

    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);
    

    【讨论】:

    • 谢谢,我不知道这个,我研究一下。我在 Github 上找到了一个库,它通过 xml 中的一行来实现效果。再次感谢您。
    【解决方案3】:

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

    https://github.com/roughike/BottomBar

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-11
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多