Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 코틀린
- 안드로이드스튜디오
- BottomSheetDialog
- 밑줄
- nav_graph
- 뷰바인딩
- textview
- Activity
- androidstudio
- RealtimeDB
- ArrayList
- Imageview
- 안드로이드
- 안드로이드 스튜디오
- button
- 랜덤ID
- ViewModel
- firebasefunctions
- MaterialButton
- OutlinedButton
- Android
- lifecyclescope
- ButtonWithButton
- Kotlin
- firebase
- ROOM
- Dialog
- FRAGMENT
- EditText
- 팝업액티비티
Archives
- Today
- Total
안드로이드 앱 개발
특정 액티비티의 상태바(statusBar) 색깔 변경 - Java, Kotlin 본문
1. java
public static void setStatusBarColor(Activity activity, int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
출처: https://androidmemo.tistory.com/11 [안드로이드 메모장]
2. Kotlin
//액티비티 상태바 수정하기
fun setStatusBarColor(activity : Activity, color : Int) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val window = activity.window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.statusBarColor = color
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
}