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
/**
 * 상태바 색상 변경..
 * */
public class Utils {
    public enum StatusBarColorType {
        BLACK_STATUS_BAR(android.R.color.black),
        PRIMARY_DARK_STATUS_BAR(R.color.colorPrimaryDark),
        WHITE_STATUS_BAR(android.R.color.white);
 
        private int backgroundColorId;
 
        StatusBarColorType(int backgroundColorId){
            this.backgroundColorId = backgroundColorId;
        }
 
        public int getBackgroundColorId() {
            return backgroundColorId;
        }
    }
 
    public static void setStatusBarColor(Activity activity, StatusBarColorType colorType) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorType.getBackgroundColorId()));
        }
    }
}
cs
1
Utils.setStatusBarColor(this, Utils.StatusBarColorType.WHITE_STATUS_BAR);
cs


'Android' 카테고리의 다른 글

ArrayList 정렬  (0) 2021.09.03
AlertDialog EditText 마진 넣기  (0) 2020.11.05
안드로이드 키보드 내리기 및 화면 리사이즈  (0) 2020.04.16
안드로이드 나만의 기본 세팅!!  (0) 2020.04.06
adb shell 명령어  (0) 2020.03.29

+ Recent posts