image.png

配置主题颜色半透明 /colors.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3. <color name="immersive_sys_ui">#33000000</color>
  4. <color name="nav_bar">@color/immersive_sys_ui</color>
  5. </resources>

设置主题/themes.xml

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->

    <style name="Theme.Hez1" parent="@style/Theme.Material.DayNight.NoActionBar">
        <item name="android:colorPrimary">#ff00ff</item>
        <item name="android:colorAccent">#ff00ff</item>
        <item name="android:statusBarColor">@color/immersive_sys_ui</item>
        <item name="android:navigationBarColor">@color/nav_bar</item>
    </style>

    <style name="Theme.Material.DayNight.NoActionBar" parent="@android:style/Theme.Material.Light.NoActionBar" />
</resources>
<resources xmlns:tools="http://schemas.android.com/tools">

    <style name="Theme.Material.DayNight.NoActionBar" parent="@android:style/Theme.Material.NoActionBar" />

</resources>

引用主题 AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.hez1">

<!--    获取网络权限-->
    <uses-permission android:name="android.permission.INTERNET" />

    <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/Theme.Hez1">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.Hez1">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>