Android status bar white background black text example code

When the company's project UI was revised, most of the title bars were designed in white. The design drawing given to us is like this:

Design drawing.png

The layout and icon of the status bar are quite like Android, but there are no black characters on a white background in the Android design specification, so we resolutely ignored this status bar when developing (most users were Android 4.4 at that time).

As a result, the designer came over with the beta and asked, why hasn't the color of your Android status bar changed.

Me: I can't do this.

The designer was skeptical.

Me: the system version above Android 4.4 can modify the color of the status bar, but only the MIUI of Xiaomi, the flyme of Meizu and the system version above Android 6.0 can change the text and icon of the status bar to dark color, and the text of other system status bars is white. If you change it to a light background, you can't see it.

The designer looked confused and didn't know what to say.

Later, when I looked at the black status bar and the white title bar, it was really ugly, and I used MIUI, so I made an adaptation.

In fact, many domestic three-party Android systems have dark status bar font mode, but at present, we only see that Xiaomi and Meizu have disclosed their implementation methods. Xiaomi supports MIUI V6 or above, and Meizu supports flyme 4.0 or above. The code is as follows:

MIUI dark status bar font mode.png

Flyme dark status bar font mode.png

The official provides a bright color status bar mode in Android 6.0. The configuration only needs one line of code:

6.0 native dark status bar font mode.png

There are many articles on status bar color setting on the Internet. The following code is my status bar setting tool class, which can be regarded as a summary.

The official version 4.4 only provides a transparent API for the status bar. We generally use the open source library systembartint to set the color of the status bar in version 4.4. Please download it yourself.

After setting the status bar to be fully transparent, the entire activity layout will move up to fill the entire screen. If you don't want the layout to move up, you need to set it in the root layout

The following sets the tool class for my status bar:

When adapting the light color status bar to the dark font, it is found that the miui7.1 system with the underlying version of Android 6.0.1 does not support view.system_ UI_ FLAG_ LIGHT_ STATUS_ For bar setting, you still have to use MIUI's own dark font method.

In July 2017, Xiaomi finally remembered to adjust the logic of character color in the status bar to be compatible with the native setting mode of Android, but did not give a method to distinguish the old system from the new system = =

Description on logical adjustment of character color in MIUI status bar

I can't help but write both methods in the place where the MIUI status bar is set.

The three-party Android system changes the bottom layer very disorderly, which is also a headache. O__ O

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>