MarshallLee
MarshallLee

Reputation: 1330

Android: How to change the navigation bar colour under Lollipop

While I can find a lot of tips of how to change the navigation bar colour above API level 21, there doesn't seem to be any suggestions for the same solution under Lollipop. Is there a way I can change its colour either programmatically or using style.xml?

Upvotes: 1

Views: 2059

Answers (1)

Tiago Sousa
Tiago Sousa

Reputation: 138

Use this on your Activity

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().setNavigationBarColor(getResources().getColor(R.color.blue));
}

Next code i gonna show only work on API versions above of 21.

<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)

I think it can only be changed by the Android versions with material design where that appear. More information here to.

Upvotes: 1

Related Questions