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: old result set navbar-color

+3


source to share


3 answers


My decision:

Issue related to generated code (XML theme), when I removed an attribute parent="android:Theme.NoTitleBar"

from my theme style (and everything else except <item name="android:navigationBarColor" tools:targetApi="21">#E64A19</item>

), my nav turned orange!



Result: screenshot with working navbar-color

+3


source


Check out this library: SystemBarTint .



This might be helpful for you.

0


source


Place this your values-v21 / styles.xml to enable this on Lollipop

0


source







All Articles