In guidelines of Android 5.0, the navigation bar seems customizable:
http://www.google.com/design/spec/layout/structure.html#structure-system-bars
How can I change the navigation bar color?
I would like to use a white style.
Screenshots:
Edit: In my resources, I tested the style:
<item name="android:navigationBarColor" tools:targetApi="21">@android:color/white</item>
But the buttons are white. I would like the same renderer as the second image.
asked Dec 7, 2014 at 21:59
alexalex
5,5816 gold badges32 silver badges54 bronze badges
1
Starting from API 27, it is now possible to use the light style of the navigation bar:
<item name="android:navigationBarColor">@android:color/white</item>
<item name="android:windowLightNavigationBar">true</item>
From the documentation:
windowLightNavigationBar
If set, the navigation bar will be drawn such that it is compatible with a light navigation bar background.
For this to take effect, the window must be drawing the system bar
backgrounds with windowDrawsSystemBarBackgrounds and the navigation
bar must not have been requested to be translucent with
windowTranslucentNavigation. Corresponds to setting
SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR on the decor view.
answered Dec 12, 2017 at 14:24
EyesClearEyesClear
27.9k7 gold badges32 silver badges43 bronze badges
5
Use this in your Activity.
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(getResources().getColor(R.color.green));
}
answered Jul 14, 2015 at 11:58
RoadiesRoadies
3,2792 gold badges29 silver badges45 bronze badges
1
add this line in your v-21/style
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/black</item>
</style>
Rahul
3,1672 gold badges28 silver badges42 bronze badges
answered Sep 3, 2016 at 14:19
HuseyinHuseyin
5396 silver badges17 bronze badges
0
This code changes the navigation bar color according to your screen background color:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.any_color));
}
You can also use the light style for the navigation bar:
<item name="android:navigationBarColor">@android:color/white</item>
Amy
95812 silver badges30 bronze badges
answered Feb 25, 2019 at 8:01
RahulRahul
3,1672 gold badges28 silver badges42 bronze badges
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(getResources().getColor(R.color.colorWhite));
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); //For setting material color into black of the navigation bar
}
Use this one if your app’s API level is greater than 23
getWindow().setNavigationBarColor(ContextCompat.getColor(MainActivity.this, R.color.colorWhite));
getWindow().getDecorView().setSystemUiVisibility(SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
May this code will not work for API level 30. Because » SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR» is deprecated in API level 30.
Check this out: https://developer.android.com/reference/android/view/View#SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
answered Mar 24, 2020 at 14:00
You can also set light system navigation bar in API 26 programmatically:
View.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
Where View coluld be findViewById(android.R.id.content).
However remember that:
For this to take effect, the window must request
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDSbut notFLAG_TRANSLUCENT_NAVIGATION.
See documentation.
answered Jun 13, 2018 at 12:01
wrozwadwrozwad
2,5801 gold badge29 silver badges38 bronze badges
getWindow().setNavigationBarColor(ContextCompat.getColor(MainActivity.this,R.color.colorPrimary)); //setting bar color
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); //additional setting items to be black if using white ui
answered Feb 2, 2020 at 15:13
Old question. But at this time we have a direct solution. May be helpful for someone.
public static void setNavigationBarColor(Activity activity, int color, int divColor) {
Window window= activity.getWindow();
window.setNavigationBarColor(color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.setNavigationBarDividerColor(divColor);
}
}
View Official Documentation
answered Jul 28, 2021 at 19:56
A Status Bar in Android is an eye-catching part of the screen, all of the notification indication, battery life, time, connection strength, and plenty of things shows here. An Android user may look at a status bar multiple times while using an Android application. It is a very essential part of the design that the color of the status bar should follow the color combination of the layout. You can look out to many android apps on your phone and can see how they changed it according to its primary colors. There can be multiple ways for changing the status bar color but we are going to tell you about the best hand-picked two methods which you can use either in Java or Kotlin.
Method 1: Creating a New Theme
You can follow this method in apps that are built with Kotlin or Java. It will work in both.
Step 1: Open Android Studio and start a new project by selecting an empty activity. Give it a name of your choice, then select your language and API level. At last click on finish.
Step 2: Find an XML file called styles.xml by navigating res/values/styles.xml.
Step 3: Find another XML file by navigating res/values/colors.xml, and also add that color here which you want to change for the status bar.
Step 4: Now in the style.xml file, add the below code just before the </resources> tag and change the colors of it as your choice. ColorPrimaryDark is always going to be responsible for your status bar color.
XML
<style name="DemoTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorOfStatusBar</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
You can do the same with android:statusBarColor but it will work only in above API Level 21. ColorPrimaryDark for the status bar will also not support in API Level 19. By default in most of the API Levels, ColorPrimaryDark will be the default color for statusBarColor, So it is good to go with changing ColorPrimaryDark.
Tip: You can create multiple themes and you can use them in any activity. In any theme, There is a set of colors that needs to be defined, you can also create new colors in the colors.xml file in the same directory and use it on the styles.xml file.
Step 6: Now go to the manifest/AndroidManifest.xml and here search the activity for which you want to apply that theme or change the color of the status bar. and add an attribute android:theme=”@style/DemoTheme”.
That’s done! Check your application by running it on an emulator or a physical device.
Method 2: Using setStatusBarColor Method
This method can be only used in the above API Level 21. Officially status bar color is not supporting below API Level 21. Although, Here we added an if condition, because in case if you haven’t selected above or equal to API 21 then it will check the android API Version, and then it will execute the code. It will not change the color of the status bar is below API Level 21 but the rest code will work well.
Step 1: After opening the android studio and creating a new project with an empty activity.
Step 2: Navigate to res/values/colors.xml, and add a color that you want to change for the status bar.
Step 3: In your MainActivity, add this code in your onCreate method. Don’t forget to replace your desired color with colorName.
Java
if (Build.VERSION.SDK_INT >= 21) {
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark));
}
Kotlin
if (Build.VERSION.SDK_INT >= 21) {
val window = this.window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.statusBarColor = this.resources.getColor(R.color.colorPrimaryDark)
}
Step 4: Try running your application on an android emulator or a physical device. See the changes.
Output for both the methods will be the same:
I was wondering if it’s possible to change the statusbar icons colour (not the statusbar colour, colorPrimaryDark)
Let’s say I want this statusbar with:
<item name="colorPrimaryDark">@android:color/white</item>
and the icons in black, is it possible?
Thanks.
EDIT:
New in the M developer preview: windowLightStatusBar. Flipping this on
in your theme tells the system to use a dark foreground, useful for
lighter colored status bars. Note the M preview seems to have a bug
where notification icons remain white, while system status icons
correctly change to semitransparent black.
from: Roman Nurik Google+ post
asked May 6, 2015 at 11:48
GuilhEGuilhE
11.5k16 gold badges74 silver badges112 bronze badges
Yes it’s possible to change it to gray (no custom colors) but this only works from API 23 and above you only need to add this in your values-v23/styles.xml
<item name="android:windowLightStatusBar">true</item>
answered Nov 24, 2015 at 13:23
eOnOeeOnOe
2,7532 gold badges12 silver badges7 bronze badges
1
@eOnOe has answered how we can change status bar tint through xml. But we can also change it dynamically in code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
View decor = getWindow().getDecorView();
if (shouldChangeStatusBarTintToDark) {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
// We want to change tint color to white again.
// You can also record the flags in advance so that you can turn UI back completely if
// you have set other flags before, such as translucent or full screen.
decor.setSystemUiVisibility(0);
}
}
answered Jun 8, 2016 at 6:06
ywwynmywwynm
11.4k7 gold badges36 silver badges53 bronze badges
5
if you have API level smaller than 23 than you must use it this way.
it worked for me declare this under v21/style.
<item name="colorPrimaryDark" tools:targetApi="23">@color/colorPrimary</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
answered Dec 30, 2016 at 4:45
RiteshRitesh
8569 silver badges14 bronze badges
3
Not since Lollipop. Starting with Android 5.0, the guidelines say:
Notification icons must be entirely white.
Even if they’re not, the system will only consider the alpha channel of your icon, rendering them white
Workaround
The only way to have a coloured icon on Lollipop is to lower your targetSdkVersion to values <21, but I think you would do better to follow the guidelines and use white icons only.
If you still however decide you want colored icons, you could use the DrawableCompat.setTint method from the new v4 support library.
answered May 6, 2015 at 11:52
Kuba SpatnyKuba Spatny
26.4k9 gold badges39 silver badges63 bronze badges
8
SystemUiVisibility flags are deprecated. Use WindowInsetsController instead
the code below sets the color of icons to black (for the light statusbar)
//icon color -> black
activity.getWindow().getDecorView().getWindowInsetsController().setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS);
and the code below clears it(i.e. turns icon color to white for dark statusbar):
//icon color -> white
activity.getWindow().getDecorView().getWindowInsetsController().setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS);
link to docs :
https://developer.android.com/reference/android/view/WindowInsetsController#setSystemBarsAppearance(int,%20int)
answered Mar 23, 2021 at 19:44
5
Setting windowLightStatusBar to true not works with Mi phones, some Meizu phones, Blackview phones, WileyFox etc.
I’ve found such hack for Mi and Meizu devices. This is not a comprehensive solution of this perfomance problem, but maybe it would be useful to somebody.
And I think, it would be better to tell your customer that coloring status bar (for example) white — is not a good idea. instead of using different hacks it would be better to define appropriate colorPrimaryDark according to the guidelines
answered Jan 22, 2018 at 9:40
Jackky777Jackky777
64412 silver badges19 bronze badges
You can do it programmatically with retaining all other system UI visibility flags.
public static void changeStatusBarContrastStyle(Window window, Boolean lightIcons) {
View decorView = window.getDecorView();
if (lightIcons) {
// Draw light icons on a dark background color
decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
// Draw dark icons on a light background color
decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
answered Oct 8, 2021 at 6:27
MahmoudMahmoud
2,5351 gold badge28 silver badges30 bronze badges
1
This is for all those who want to change their application’s Notification small icon color can use this setColor method of NotificationCompat.Builder
Example:
val builder = NotificationCompat.Builder(this, "whatever_channel_id")
**.setSmallIcon(R.drawable.ic_notification) //set icon for notification**
.setColor(ContextCompat.getColor(this, R.color.pink))
.setContentTitle("Notification Title")
.setContentText("Notification Message!")
answered Mar 4, 2021 at 15:51
Kishan SolankiKishan Solanki
13.2k4 gold badges80 silver badges79 bronze badges
I used two line of code for different status bar color
1st: If status bar color is white then use this line of code to visible the status bar icon:
pingAct.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
2nd: If you use dark color then use this line of code to make visible the status bar icon:
pingAct.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
answered Oct 12, 2022 at 15:48
Pir Fahim ShahPir Fahim Shah
10.3k1 gold badge79 silver badges79 bronze badges
in kotlin you can use following lines
val window = this.window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = ContextCompat.getColor(this, R.color.white)
WindowCompat.getInsetsController(window, window.decorView).apply {
isAppearanceLightStatusBars = true
}
answered Jan 24 at 11:39
Yes you can change it. but in api 22 and above, using NotificationCompat.Builder and setColorized(true) :
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, context.getPackageName())
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(icon, level)
.setLargeIcon(largeIcon)
.setContentIntent(intent)
.setColorized(true)
.setDefaults(0)
.setCategory(Notification.CATEGORY_SERVICE)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(NotificationCompat.PRIORITY_HIGH);
answered Nov 16, 2018 at 13:55
2
I was wondering if it’s possible to change the statusbar icons colour (not the statusbar colour, colorPrimaryDark)
Let’s say I want this statusbar with:
<item name="colorPrimaryDark">@android:color/white</item>
and the icons in black, is it possible?
Thanks.
EDIT:
New in the M developer preview: windowLightStatusBar. Flipping this on
in your theme tells the system to use a dark foreground, useful for
lighter colored status bars. Note the M preview seems to have a bug
where notification icons remain white, while system status icons
correctly change to semitransparent black.
from: Roman Nurik Google+ post
asked May 6, 2015 at 11:48
GuilhEGuilhE
11.5k16 gold badges74 silver badges112 bronze badges
Yes it’s possible to change it to gray (no custom colors) but this only works from API 23 and above you only need to add this in your values-v23/styles.xml
<item name="android:windowLightStatusBar">true</item>
answered Nov 24, 2015 at 13:23
eOnOeeOnOe
2,7532 gold badges12 silver badges7 bronze badges
1
@eOnOe has answered how we can change status bar tint through xml. But we can also change it dynamically in code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
View decor = getWindow().getDecorView();
if (shouldChangeStatusBarTintToDark) {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
// We want to change tint color to white again.
// You can also record the flags in advance so that you can turn UI back completely if
// you have set other flags before, such as translucent or full screen.
decor.setSystemUiVisibility(0);
}
}
answered Jun 8, 2016 at 6:06
ywwynmywwynm
11.4k7 gold badges36 silver badges53 bronze badges
5
if you have API level smaller than 23 than you must use it this way.
it worked for me declare this under v21/style.
<item name="colorPrimaryDark" tools:targetApi="23">@color/colorPrimary</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
answered Dec 30, 2016 at 4:45
RiteshRitesh
8569 silver badges14 bronze badges
3
Not since Lollipop. Starting with Android 5.0, the guidelines say:
Notification icons must be entirely white.
Even if they’re not, the system will only consider the alpha channel of your icon, rendering them white
Workaround
The only way to have a coloured icon on Lollipop is to lower your targetSdkVersion to values <21, but I think you would do better to follow the guidelines and use white icons only.
If you still however decide you want colored icons, you could use the DrawableCompat.setTint method from the new v4 support library.
answered May 6, 2015 at 11:52
Kuba SpatnyKuba Spatny
26.4k9 gold badges39 silver badges63 bronze badges
8
SystemUiVisibility flags are deprecated. Use WindowInsetsController instead
the code below sets the color of icons to black (for the light statusbar)
//icon color -> black
activity.getWindow().getDecorView().getWindowInsetsController().setSystemBarsAppearance(APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS);
and the code below clears it(i.e. turns icon color to white for dark statusbar):
//icon color -> white
activity.getWindow().getDecorView().getWindowInsetsController().setSystemBarsAppearance(0, APPEARANCE_LIGHT_STATUS_BARS);
link to docs :
https://developer.android.com/reference/android/view/WindowInsetsController#setSystemBarsAppearance(int,%20int)
answered Mar 23, 2021 at 19:44
5
Setting windowLightStatusBar to true not works with Mi phones, some Meizu phones, Blackview phones, WileyFox etc.
I’ve found such hack for Mi and Meizu devices. This is not a comprehensive solution of this perfomance problem, but maybe it would be useful to somebody.
And I think, it would be better to tell your customer that coloring status bar (for example) white — is not a good idea. instead of using different hacks it would be better to define appropriate colorPrimaryDark according to the guidelines
answered Jan 22, 2018 at 9:40
Jackky777Jackky777
64412 silver badges19 bronze badges
You can do it programmatically with retaining all other system UI visibility flags.
public static void changeStatusBarContrastStyle(Window window, Boolean lightIcons) {
View decorView = window.getDecorView();
if (lightIcons) {
// Draw light icons on a dark background color
decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
// Draw dark icons on a light background color
decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
answered Oct 8, 2021 at 6:27
MahmoudMahmoud
2,5351 gold badge28 silver badges30 bronze badges
1
This is for all those who want to change their application’s Notification small icon color can use this setColor method of NotificationCompat.Builder
Example:
val builder = NotificationCompat.Builder(this, "whatever_channel_id")
**.setSmallIcon(R.drawable.ic_notification) //set icon for notification**
.setColor(ContextCompat.getColor(this, R.color.pink))
.setContentTitle("Notification Title")
.setContentText("Notification Message!")
answered Mar 4, 2021 at 15:51
Kishan SolankiKishan Solanki
13.2k4 gold badges80 silver badges79 bronze badges
I used two line of code for different status bar color
1st: If status bar color is white then use this line of code to visible the status bar icon:
pingAct.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
2nd: If you use dark color then use this line of code to make visible the status bar icon:
pingAct.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
answered Oct 12, 2022 at 15:48
Pir Fahim ShahPir Fahim Shah
10.3k1 gold badge79 silver badges79 bronze badges
in kotlin you can use following lines
val window = this.window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = ContextCompat.getColor(this, R.color.white)
WindowCompat.getInsetsController(window, window.decorView).apply {
isAppearanceLightStatusBars = true
}
answered Jan 24 at 11:39
Yes you can change it. but in api 22 and above, using NotificationCompat.Builder and setColorized(true) :
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, context.getPackageName())
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(icon, level)
.setLargeIcon(largeIcon)
.setContentIntent(intent)
.setColorized(true)
.setDefaults(0)
.setCategory(Notification.CATEGORY_SERVICE)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(NotificationCompat.PRIORITY_HIGH);
answered Nov 16, 2018 at 13:55
2
7 ответов
Вы можете изменить его, установив android:statusBarColor или android:colorPrimaryDark стиля, который вы используете для своего приложения, в styles.xml.
(android:statusBarColor наследует значение android:colorPrimaryDark по умолчанию)
Например (поскольку здесь мы используем тему AppCompat, пространство имен android опущено):
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">@color/your_custom_color</item>
</style>
На уровне API 21+ вы также можете использовать метод Window.setStatusBarColor() из кода.
Из его документов:
Чтобы это вступило в силу, окно должно рисовать фоны системной панели с помощью
WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDSиWindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUSне должны быть установлены. Если цвет непрозрачен, рассмотрите возможность установкиView.SYSTEM_UI_FLAG_LAYOUT_STABLEиView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN.
earthw0rmjim
06 сен. 2016, в 07:24
Поделиться
Строка состояния — системное окно, принадлежащее операционной системе.
На устройствах до 5.0 для Android приложения не имеют права изменять свой цвет, поэтому это не то, что библиотека AppCompat может поддерживать более старые версии платформы. Лучшим AppCompat может служить поддержка окраски ActionBar и других общих виджетах пользовательского интерфейса в приложении.
На устройствах после 5.0 для Android
Изменение цвета строки состояния также требует установки двух дополнительных флагов в окне; вам нужно добавить флаг FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS и очистить флаг FLAG_TRANSLUCENT_STATUS.
Window window = activity.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// finally change the color
window.setStatusBarColor(activity.getResources().getColor(R.color.my_statusbar_color));
salik latif
06 сен. 2016, в 08:02
Поделиться
Вы также можете добавить эти строки кода в основное действие
if (Build.VERSION.SDK_INT >= 21) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.dark_nav)); // Navigation bar the soft bottom of some phones like nexus and some Samsung note series
getWindow().setStatusBarColor(ContextCompat.getColor(this,R.color.statusbar)); //status bar or the time bar at the top
}
Faakhir
16 нояб. 2017, в 06:46
Поделиться
изменение цвета строки состояния доступно только для Android выше леденец
1. Вы можете изменить цвет строки состояния программно этой строкой:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(context, R.color.your_color));
}
2. Вы можете сделать это с плавной анимацией перехода:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int startColor = getWindow().getStatusBarColor();
int endColor = ContextCompat.getColor(context, R.color.your_color);
ObjectAnimator.ofArgb(getWindow(), "statusBarColor", startColor, endColor).start();
}
3. или вы можете добавить это к вашему стилю темы в файле values /styles.xml. Элемент colorPrimaryDark будет использоваться для цвета строки состояния вашего приложения
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
shahab yousefi
10 окт. 2018, в 23:05
Поделиться
<item name="colorPrimaryDark">@color/your_color</item>
будет отображаться только в Lollipop и больше, чем Lollipop (API).
Постскриптум вам необходимо иметь Theme.AppCompat в качестве основной/основной темы
Aman Grover
06 сен. 2016, в 06:51
Поделиться
добавить цвет строки состояния к вашему стилю и готово
<item name="android:statusBarColor">@color/black</item>
Masoud Darzi
27 янв. 2019, в 10:39
Поделиться
Примечание. — Цвет строки состояния поддерживается на уровне api 19 или 21 и выше уровня api.
Проверьте эту ссылку: изменить цвет строки состояния
Krunal Patel
06 сен. 2016, в 06:26
Поделиться
Ещё вопросы
- 0диалоговое окно отображается автоматически при загрузке веб-страницы
- 12 односвязных пересечения списка
- 1Добавить таймер для изображений в javafx
- 0Правильный способ в PHP для форматирования / экранирования строки для использования в XML
- 0CSS лайтбокс Формодержатель
- 1Как создать и стилизовать ComboBox с двумя столбцами в WPF
- 0Ошибка JQuery: что это?
- 1Удалить жесты из RatingBar
- 1ProgressDialog не появляется, пока не стало слишком поздно
- 0Переменные Opencv, не объявленные в этой области
- 1Точность застряла на 50% керас
- 0Как изменить положение значка в ионной вкладке, которая только для заголовка?
- 0Mysql сгруппировать по column1, column2 «Desc | asc» без ошибок
- 0Расширение Magento Checkout — перейти к следующему шагу в Checkout
- 0Невозможно отобразить растровое изображение и текст на CMfcButton: отображается только изображение
- 1Запустите скрипт Python на терминале и продолжайте использовать терминал позже [duplicate]
- 0Основы стеков
- 1Ошибка при подключении к Estimote Beacon iOS
- 0Локальная переменная в представлении AngularJS
- 0динамический объект массива json
- 0Подсчет предметов с состоянием true в угловом повторителе
- 1Как именно работает эта пользовательская директива Angular 2?
- 1Как использовать несколько обратных вызовов при зацикливании данных
- 0Двухстороннее крепление для углового ремня
- 1программно получить базовый URL из метода конечной точки ядра приложения Google
- 1Пользовательские ошибки компилятора через участников компиляции
- 0Странное связующее постоянство между контроллерами
- 1Какой лучший способ для приложения Android прослушивать поступающие сообщения TCP / IP?
- 0Тест транспортира генерирует исключение «недопустимое состояние элемента», как только я добавляю утверждение «ожидаю»
- 0Манипуляции с атрибутом HTML5 <audio> / <source> с помощью JQuery
- 1Слияние значений в панде DF
- 0невозможно выровнять элемент в HTML-форме
- 0Управляйте пользователями с помощью Firebase, но сохраняйте пользовательское видео в MySQL
- 0div не может анимировать нижнюю сторону и выходит из экрана окна со всех сторон
- 1изменение ориентации Android по вертикали вправо
- 0Обновление mysql увеличивается только один раз
- 0Развертывание SpringBoot / Hibernate с MySQL в Windows не работает, изначально разработано для Linux — SQLGrammarException
- 0Подходим строки с акцентами
- 1Ограничения веб-служб Exchange (EWS)
- 0Как я могу получить значение по умолчанию столбца для пустой таблицы в MySQL?
- 1Tensorflow не хватает памяти, когда я меняю свой оптимизатор
- 0Какова цель helper.basepath в угловом интерфейсе?
- 1Как передать переменную и JSON в веб-сервис.
- 0Поиск следующего элемента ввода после тега комментария
- 0Возвращение списка значений в виде текстовой строки в одном столбце из подзапроса в MySQL
- 1Подсчет количества строк, заполненных кортежами
- 0Проверьте вход в AngularJS
- 1не получить результат с помощью SharedPreferences в Android
- 0Как привязать значение поля ввода к параметрам?
- 1Здравствуйте, Google Maps Пример NULL Указатель Исключение











