Set navigation color to Android Lollipop with full screen mode
Is there a way to set the color of the navbar in full screen mode?
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(getResources().getColor(R.color.Theme_color));
And this line in my theme style:
<item name="android:navigationBarColor" tools:targetApi="21">#E64A19</item>
Both are obtained in the same transparent navbar above my behavior ...
code:
Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow()
.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_account);
if (getResources().getBoolean(R.bool.portrait_only)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow()
.setNavigationBarColor(getResources().getColor(R.color.Theme_color));
}
//other code ... (irrelevant)
Topic:
<style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@null</item>
<item name="metaButtonBarStyle">@style/ButtonBar</item>
<item name="metaButtonBarButtonStyle">@style/ButtonBarButton</item>
<item name="android:navigationBarColor" tools:targetApi="21">#E64A19</item>
</style>
The result is a black navigation bar. But I want an orange (# E64A19) navigation bar.
Result:
+3
source to share
3 answers