Android lollipop change navigation bar color
It can be done inside styles.xml using
<item name="android:navigationBarColor">@color/theme_color</item>
or
window.setNavigationBarColor(@ColorInt int color)
http://developer.android.com/reference/android/view/Window.html#setNavigationBarColor(int)
Note that the method was introduced in Android Lollipop and won't work on API version < 21.
The second method (works on KitKat) is to set windowTranslucentNavigation to true in the manifest and place a colored view beneath the navigation bar.
android change navigation bar color
You can do it by adding this statement in styles
<item name="android:navigationBarColor">@color/theme_color</item>
or this in the main java
window.setNavigationBarColor(@ColorInt int color);
How to change the color of the navigation bar from an input method service?
Try using getWindow().getWindow()
inside the InputMethodService
instead of just the single getWindow()
call.
It seems that the first getWindow()
call returns a SoftInputWindow
which is a type of Dialog
, but you can call getWindow()
again on it to get a PhoneWindow
that is a proper Window
, and that has the function you're looking for.
If you need a full example to look at, here's a code sample from Google's own codebase. I ran into this problem recently myself and this example is how I figured out how to do it.
How to change color of navigation bar (gesture mode)?
You can set the color of navigation bar like so:
val window: Window = this@MainActivity.window
window.navigationBarColor = ContextCompat.getColor(this@MainActivity, R.color.yourColor)
And you'll have to set your color in res/values/colors.xml:
<color name="yourColor">#0D0D0D</color>
Unable to change Navbar Color
While fixing another issue I had to change and minimum API level to
Lollipop and noticed that
<itemname="android:navigationBarColor">@color/theme_color</item>
started working when minimum API level is set to Lollipop.
So I think for some reason Xamarin requires to use use Minimum API version Lollipop for this to work
How to set the background color of system navigation bar to the one of the new Bottom Navigation bar in Material 3? (Android)
There is a new class in Material Components library in version 1.5.0 (specifically 1.5.0-alpha03) and up that solves this very problem, the SurfaceColors class.
To use it, call the getColor
method on one of the constant values in the SurfaceColors
enum for the desired color. Here is an example:
getWindow().setNavigationBarColor(SurfaceColors.SURFACE_2.getColor(this));
SURFACE_2
is what is used (or its equivalent) by BottomNavigationView
. It works with and without Dynamic Coloring (including night mode). I have also observed this solution being used in the Files by Google app.
Here is a screenshot on Android 11
And here is a screenshot on Android 12.1 with Dynamic Coloring
If you're also curious about the exact shadow used by Google for the BottomNavigationView
, it is a 5dp tall gradient drawable from #00000000 to #33333333.
Related Topics
Android- Create JSON Array and JSON Object
Android Asynctask Threads Limits
Google Play Services Library Update and Missing Symbol @Integer/Google_Play_Services_Version
Storing R.Drawable Ids in Xml Array
Android: How to Check If Activity Is Running
How to Update UI in a Broadcastreceiver
Is There Any Way in Android to Get the Height of Virtual Keyboard of Device
Parse Dynamic Key JSON String Using Retrofit
Android Studio - Mergedebugresources Exception
Android Alarmmanager Not Working on Some Devices When the App Is Closed
Start_Sticky Does Not Work on Android Kitkat
Android - iPhone Style Tabhost
Android Popupwindow with Tooltip Arrow
Change Locale Not Work After Migrate to Androidx
App Is Misconfigured for Facebook Login: Android Facebook Integration Issue
Requestfeature() Must Be Called Before Adding Content
What Is Different Between Mainactivity.This VS Getapplicationcontext()
Published App on Play Store Can't Communicate with Google Maps API and Facebook API