코딩하는 일용직 노동자

안드로이드 StatusBar 색상 변경하기. (Kotlin) 본문

안드로이드

안드로이드 StatusBar 색상 변경하기. (Kotlin)

bacass 2020. 5. 3. 15:45

# 방법1
res/style.xml 파일 수정.

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textViewStyle">@style/TextViewStyle</item>
</style>

 

메니페스트 파일에서 theme 에 설정.

<application
    android:name=".MyApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:networkSecurityConfig="@xml/network_security_config"
    android:roundIcon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">



# 방법2

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setStatusBarColor()

    window.statusBarColor = Color.parseColor("#ff0000")
}    

status bar color