Android 自定义Appbar不更改颜色
即使我在自定义主题的样式中定义了colorPrimaryDark,appbar仍保持半透明。代码的重要部分如下所示 styles.xmlAndroid 自定义Appbar不更改颜色,android,android-layout,android-theme,Android,Android Layout,Android Theme,即使我在自定义主题的样式中定义了colorPrimaryDark,appbar仍保持半透明。代码的重要部分如下所示 styles.xml <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrima
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
假的
真的
这是appbar布局中的工具栏:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id = "@+id/appBar"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" android:titleTextColor="#FFFFFF"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
这是我在清单中为该活动定义的:
<activity
android:name=".Activity5"
android:label="Activity5"
android:parentActivityName=".MainActivity"
android:theme="@style/AppTheme.NoActionBar" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.divya.sampleapplication.MainActivity" />
</activity>
任何关于我错在哪里的建议。其他所有东西,如工具栏,都工作正常。请尝试更改此行
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
到
只需在清单中的标记中添加什么是主题?Apptheme。android:theme=“@style/AppTheme”尝试过。不工作。相反,标题颜色变为黑色。已还原更改。祝您好运,希望您能找到答案
<style name="AppTheme.AppBarOverlay" parent="AppTheme" />