java - Animate Status Bar Color on DrawerLayout - Material Design -
I am writing a simple app that implements the physical design analog dos drawer described by this stack post:
ScrimInsetsFrameLayout
does great work and everything is bound until it tries to change the color of the status bar of the program bar to change the toolbar and status bar color dynamically. My app uses the Palette API.
I am using the toolbar to animate and it works great! But I try to do the same animation on the sitemap and it does not seem to have animate. Here is an example
here Code for my animator:
public static void fadeStatusBar (final DrawerLayout layout, for integer integer,), {if (android.os.Build.VERSION.SDK_INT> = Build. VERSION_CODES.LOLLIPOP) {ValueAnimator colorAnimation = ValueAnimator.ofObject (from the new ArgbEvaluator (), from, to); colorAnimation.addUpdateListener (New ValueAnimator.AnimatorUpdateListener () {@Override public void onAnimationUpdate (ValueAnimator animator) {layout.setStatusBarBackgroundColor ((int) animator.getAnimatedValue ());}}); ColorAnimation.start (); }}
Note: This code toolbar is missing, so it is proven to work.
My question is; ? When using the DrawerLayout.setStatusBarBackgorundColour ()
note to get a better way, I know about the window.setStatusBarColor () window method Used
method, and it animates fine, but when NavDrawer is pulled, it breaks the "transparent status bar".
Respond to @adneal's comment on your original question as answer to cancel viewing during the animation Was done for.
DrawerLayout calculates top inset and leave the status bar in the background only. Therefore, animation updates, while you need to call View.invalidate forced to rebuild it again. @adneal
I've updated my code to the
from ValueAnimator colorAnimation = ValueAnimator.ofArgb (to); colorAnimation.addUpdateListener (New ValueAnimator.AnimatorUpdateListener () {@Override public void onAnimationUpdate (ValueAnimator animator) {layout.invalidate (); layout.setStatusBarBackgroundColor ((int) animator.getAnimatedValue ());}}); ColorAnimation.start ();
Why did it work for anyone thinking it, I stack post illuminated:
Comments
Post a Comment