코틀린 안드로이드 스튜디오 다크모드 비활성화

2024. 1. 10. 12:42- 안드로이드/kotlin

디바이스 기기의 설정이 다크모드로 되어 있을때 앱을 실행하면 다크모드 화면으로 변경되는데 그렇게 되면 다크모드 일때와 아닐때 두가지 모드에 맞춰 개발을 해야 합니다. 이럴때 그냥 기기 설정이 다크모드 여도 앱에서는 다크모드를 비활성화 할수가 있는데요 간단히 한줄만 변경해주면 됩니다.

 

res > values > themes > themes.xml (night) 파일을 수정합니다.

 

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Base.Theme.MvvmInsta" parent="Theme.Material3.DayNight.NoActionBar">
        <!-- Customize your dark theme here. -->
        <!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
    </style>
</resources>

 

parent="Theme.Material3.DayNight.NoActionBar" 의 DayNight을 Light 으로 바꿔주면 다크모드가 비활성화 됩니다.