android操作顶部状态栏
一、在AndroidManifest.xml文件中:
引入样式AppTheme:
<application android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">-->设置顶部样式
<activity android:name=".MainActivity">
二、values–>styles 文件中:
定义样式:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- 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>-->设置为true
</style></resources>
注:<style name 属性与 AndroidManifest.xml文件中 @style/AppTheme 中 AppTheme 对应
values–>colors文件中:
设置对应颜色:
<?xml version="1.0" encoding="utf-8"?>
<resources> <color name="colorPrimary">#ffffffff</color>
<color name="colorPrimaryDark">#ffffffff</color>
<color name="colorAccent">#D81B60</color></resources>