액티비티의 onCreate() 레이아웃호출 위에 삽입
// 상태바 아이콘을 밝게(흰색) 변경
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
getWindow().setStatusBarColor(getResources().getColor(R.color.gray));//본인이 설정
// 상태바 아이콘을 밝게(흰색) 변경
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WindowInsetsController insetsController = getWindow().getDecorView().getWindowInsetsController();
if (insetsController != null) {
insetsController.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS,
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS);
}
} else {
// API 30 미만 버전 호환성
WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView()).setAppearanceLightStatusBars(true);
}
getWindow().getDecorView().setOnApplyWindowInsetsListener((v, insets) -> {
int systemBarInsetTop = insets.getSystemWindowInsetTop();
int systemBarInsetBottom = insets.getSystemWindowInsetBottom();
v.setPadding(0, systemBarInsetTop, 0, systemBarInsetBottom);
return insets;
});'안드로이드 개발 > 개발팁' 카테고리의 다른 글
| No adapter attached; skipping layout 발생 이유 (0) | 2026.02.15 |
|---|---|
| 구글공식사이트에서 구버전 안드로이드스튜디오 다운받기 (1) | 2025.09.01 |
| AGP와 Gradle 버전 맞추기 (2) | 2025.08.04 |
| 반드시 CoroutineScope를 직접 써야 하는 예시 (공식문서 기반) (0) | 2025.07.17 |
| 코루틴 스코프 쉽게 외우기 (1) | 2025.06.28 |