Changing the Status Bar Text Color in Android Studio

Changing the Status Bar Text Color in Android Studio

When developing an Android app, there are often situations where you need to change the color of the status bar text.

This blog post will briefly introduce how to change the status bar text color in Android Studio.

Code Example

Java

View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(0);

This code makes the status bar transparent and sets the text color to the system default.

Note: This code only works on API level 21 and above.

Changing the Text Color

To directly set the status bar text color, use the following code:

Java

int color = Color.parseColor("#ffffff"); // Change to your desired color code
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
getWindow().setStatusBarColor(color);

Precautions

  • The text color may be displayed differently depending on the app’s theme.
  • Changing the text color may not be supported on some devices.

Conclusion

This blog post briefly introduced how to change the status bar text color in Android Studio.

For more information, please refer to the official documentation linked above.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다