android - 动画导航栏颜色Android

标签 android android-5.0-lollipop

我有自己的风格

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="MYTheme" parent="...">
        <item name="android:navigationBarColor">@color/navigationBarColor</item>
    </style>
</resources>

我知道我可以更改导航栏的颜色

getWindow().setNavigationBarColor(...);

我想用动画改变颜色,当前颜色和新颜色之间的过渡

最佳答案

您可以使用 ValueAnimator.ofArgb 动画颜色变化。我必须提到它只支持从 API >= 21 开始。不过这应该不是问题,因为 setNavigationBarColor 也是 >= 21。

int from = getWindow().getNavigationBarColor();
int to = Color.BLACK; // new color to animate to

ValueAnimator colorAnimation = ValueAnimator.ofArgb(from, to);
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animator) {
        getWindow().setNavigationBarColor((Integer) animator.getAnimatedValue());
    }
});
colorAnimation.start();

关于android - 动画导航栏颜色Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30158986/

相关文章:

android - 如何控制 Android ImageSwitcher 中的过渡持续时间

android - Canvas.getClipBounds 是否分配一个 Rect 对象?

colors - Android L - SwipeRefreshLayout 配色方案的 Material 设计

java - Realm 和预期的 BEGIN_OBJECT,但在路径 $[0].location.coordinates[0] 处为 NUMBER

android - 在 Android 中创建计时器

java - 我怎样才能得到句子中的确切单词

android - 我想使用 android L 主题

android - 替代布局

Android Lollipop EditText : AutoComplete Not Working For Email Addresses

android - appcompat v7 23,操作栏,透明度