Skip to content

Commit

Permalink
color the status bar and navigation bar
Browse files Browse the repository at this point in the history
  • Loading branch information
colbylwilliams committed Nov 22, 2016
1 parent 9e3aec3 commit 4abfb90
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions XWeather/Droid/Activities/WeatherActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
using System.Threading.Tasks;

using Android.App;
using Android.Animation;
using Android.Graphics;
using Android.Graphics.Drawables;
using Android.OS;
using Android.Views;
using Android.Views.Animations;

using Android.Support.Design.Widget;
using Android.Support.V4.View;
Expand Down Expand Up @@ -157,6 +160,9 @@ void updateBackground ()

viewPager.Background = gd;

Window.SetStatusBarColor (gradients.Item1 [0]);
Window.SetNavigationBarColor (gradients.Item1 [1]);

} else {

var backgrounds = new Drawable [2];
Expand All @@ -169,6 +175,37 @@ void updateBackground ()
viewPager.Background = crossfader;

crossfader.StartTransition (1000);

var statusBarAnimator = ValueAnimator.OfArgb (Window.StatusBarColor, gradients.Item1 [0]);

statusBarAnimator.SetDuration (1000);
statusBarAnimator.SetInterpolator (new AccelerateDecelerateInterpolator ());

statusBarAnimator.Update += (sender, e) => {

var val = e.Animation.AnimatedValue as Java.Lang.Integer;

var color = new Color ((int)val);

Window.SetStatusBarColor (color);
};

var naviationBarAnimator = ValueAnimator.OfArgb (Window.NavigationBarColor, gradients.Item1 [1]);

naviationBarAnimator.SetDuration (1000);
naviationBarAnimator.SetInterpolator (new AccelerateDecelerateInterpolator ());

naviationBarAnimator.Update += (sender, e) => {

var val = e.Animation.AnimatedValue as Java.Lang.Integer;

var color = new Color ((int)val);

Window.SetNavigationBarColor (color);
};

statusBarAnimator.Start ();
naviationBarAnimator.Start ();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion XWeather/Droid/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="143"
android:versionCode="150"
android:versionName="0.5.6"
package="com.xamarin.xweather">
<uses-sdk
Expand Down

0 comments on commit 4abfb90

Please sign in to comment.