我有自己的风格
<?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/