styles.xml 정의
1
2
3
4
5
6
|
<style name="AppTheme.StatusBar" parent="AppTheme">
<!--Status Bar 배경색-->
<item name="android:statusBarColor">#ffffff</item>
<!--Status Bar 글자색깔-->
<item name="android:windowLightStatusBar">true</item>
</style>
|
cs |
AndroidManifest.xml에 적용
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.IntroActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.StatusActivity"
android:theme="@style/AppTheme.StatusBar" />
</application>
|
cs |
앱 전체에 적용할 경우 application의 android:theme로 적용하면 된다.
특정 액티비티에서만 적용할 경우 activity의 android:theme에 적용하면 된다.
액티비티 단 Code 정의
1
2
3
4
5
6
7
8
9
10
11
|
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);
}
}
|
cs |
특정 액티비티에 적용 시 Code로 적용이 가능하다.
주의 할 점
Status Bar 색상변경은 android 5.0(Lollipop - API 21)부터 사용되며,
Status Bar Text 색상변경은 android 6.0(Marshmallow - API 23)부터 사용할 수 있다.
Status Bar Text 색상변경의 경우 흰색 or 검정색으로만 변경이 가능하며 직접 색상을 지정 할 수는 없다.
Android Log 표시(Log 짤림 현상 개선) (0) | 2017.12.04 |
---|---|
android 디바이스에 저장된 연락처 가져오기 (0) | 2017.10.17 |
android 단말기내 어플리케이션(앱) 설치 여부 확인 방법 (0) | 2016.12.05 |
android '최근 실행 목록'에서 실행 시 구분 (0) | 2016.12.05 |
android SpannableStringBuilder (0) | 2016.12.05 |
댓글 영역