티스토리 뷰
Android Q부터 시스템에서 Dart Theme 를 제공한다.
Dark 테마의 여러 이점
-
전력 사용량을 줄인다.
-
조도가 낮은 환경에서 사용 용이
-
밝은 빛에 민감한 사용자의 가시성 향상
Android Q에서 다크 테마를 활성화하는 세 가지 방법
-
새 시스템 설정 : Settings -> Display -> Theme
-
알림 트레이에서 테마 변경
-
픽셀기기에서는 배터리 보호기 모드에서도 다크 테마가 활성화된다. (다른 OEM들에서는 이 행동을 지원수도 있고 그렇지 않을 수도있다.)
다크 테마 적용
res/values/styles.xml 에서 아래와같이 다크테마를 적용할 수 있다.
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
Meterialcomponent 의 Dark theme setting
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
Configuration changes
activity의 configChanges에 uiMode를 설정하면
<activity android:name=".MyActivity" android:configChanges="uiMode" />
시스템에서 다크모드가 활성화될때
onConfigurationChanged()를 통해 변경된 모드를 알 수 있다.
val currentNightMode = configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
when (currentNightMode) {
Configuration.UI_MODE_NIGHT_NO -> {} // Night mode is not active, we're using the light theme
Configuration.UI_MODE_NIGHT_YES -> {} // Night mode is active, we're using dark theme
}
발췌 : https://developer.android.com/preview/features/darktheme#kotlin
'개발 > ANDROID' 카테고리의 다른 글
비트맵을 겹쳐서 OOM 극복하기 (0) | 2019.04.01 |
---|---|
[트랜스퍼모드] xPermode 적용기 (0) | 2019.02.11 |
와이파이 다이렉트 (0) | 2018.11.08 |
안드로이드 투명 인디케이터 만들기 (0) | 2018.10.17 |
fontFamily (0) | 2018.10.15 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크