3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Kotlin 初心者】ステータスバーの色変更方法

Posted at

ステータスバーの色変更方法

Androidアプリを作る際にステータスバーを適宜変更する必要があるかと思います。いつもやり方忘れるのでメモ変わりとして残ります

イメージ画像

image.png

変更方法

まずはAndroidManifestでThemaを変更していきます
android:theme="@style/statusbar.theme">AndroidManifestのthemeを変更します

/app/src/main/AndroidManifest.xml

<application
        android:name="core.CoettoApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="Coetto"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/statusbar.theme">

statusbar.xmlに好きな配色で指定すれば変更完了です!

themes.xml
<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="statusbar.theme" parent="Theme.AppCompat.DayNight.NoActionBar">

        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>

        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/purple_200</item>
        <item name="colorPrimaryVariant">@color/white</item>
        <item name="android:textColorPrimary">@color/white</item>
        <item name="android:background">@color/white</item>
        <item name="colorOnPrimary">@color/white</item>
        <item name="colorOnSecondary">@color/white</item>
        <item name="android:windowLightStatusBar">true</item>
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
    </style>
</resources>
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?