Android 在API M以後最簡單設置狀態欄字體顏色爲黑色的方法

Android 在API M以後最簡單設置狀態欄字體顏色爲黑色的方法

前言

當UI設計給的狀態欄文字爲黑色的時候,按照以前的做法,就是使用一個第三方庫,雖然挺好用的,但總歸是會存在一些彆扭的問題。

具體使用方法看這裏:Android 最好用的沉浸式狀態欄和沉浸式導航欄管理

修改狀態欄文字黑色

按下方例子在style中修改即可。

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.DayNight.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:windowLightStatusBar" tools:targetApi="m">true</item>
    </style>

完事

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章