Change Status Bar Color Android Kotlin

Changing the android status bar color is very easy in android studio.
Change status bar color android kotlin. This example demonstrates how to change status bar color to match app android using kotlin. New project and fill all required details to create a new project. Step 1 create a new project in android studio go to file new project and fill all required details to create a new project. Step 1 create a new project in android studio go to file.
An extension to the sushant s answer since getcolor is deprecated and in kotlin language. When android windowlightstatusbar is set to true status bar text color will be able to be seen when the status bar color is white and when android windowlightstatusbar is set to false status bar. Android lollipop brought with it the ability to change the color of status bar in your app for a more immersive user experience and in tune with google s material design guidelines. Changing the color of the status bar is available only for devices with android lollipop api 21 and higher.
Step 2 add the following code to res layout activity main xml. When the example kotlin android application is run on an android device conclusion. This example demonstrates how to hide status bar in android using kotlin. Requiresapi build version codes lollipop fun backgroundcolor window addflags windowmanager layoutparams flag draws system bar backgrounds window statusbarcolor contextcompat getcolor this android r color transparent window navigationbarcolor contextcompat getcolor this android r color.
In this kotlin android tutorial we have learnt to change snackbar s text color background color action button text color. Here is how you can change the color of the status bar using the new window setstatusbarcolor method introduced in api level 21. Set color on android colorprimarydark the attribute of the style you re using for your app in styles xml. Therefore we would have to add a line of code that would check if the android version is at lease 21 or not and then try to change the color of the status bar.
How to change progress bar color in android programmatically. Platform android studio google play jetpack kotlin docs news language english bahasa indonesia deutsch español español américa latina français português brasil tiếng việt türkçe русский ภาษาไทย 中文 简体 中文 繁體 日本語 한국어.