我的工具栏像这样透明; enter image description here
和代码在这里,textApperarance无法正常工作,我尝试了其他的东西,比如“android:textColorPrimary”
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="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>
</style>
<style name="AppTheme.ActionBar.Transparent" parent="AppTheme">
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBarOverlay">true</item>
<item name="colorPrimaryDark">@color/gray</item>
<item name="colorPrimary">@android:color/transparent</item>
<item name="android:textAppearance">@style/TitleTextColor</item>
</style>
<style name="TitleTextColor">
<item name="android:textColor">@color/red</item>
</style>
并且有androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<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.ActionBar.Transparent">
<activity android:name=".MainActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddNote"></activity>
</application>
答案 0 :(得分:0)
只需替换这个 -
<style name="AppTheme.ActionBar.Transparent" parent="AppTheme">
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBarOverlay">true</item>
<item name="colorPrimaryDark">@color/gray</item>
<item name="colorPrimary">@android:color/transparent</item>
<item name="android:textAppearance">@style/TitleTextColor</item>
</style>
这一个
<style name="AppTheme.ActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBarOverlay">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textAppearance">@style/TitleTextColor</item>
</style>