英文:
How to change Actionbar text color using Material Design?
问题
I am using Material Design in my Android app and I want to change Actionbar text color and back button color.
This code is not working:
<style name="AppTheme" parent="Theme.MaterialComponents.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:windowContentOverlay">@null</item>
<!-- <item name="android:textSize">3sp</item> -->
<item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/titleColor</item>
</style>
Is there anything else you need assistance with?
英文:
I am using Material Design in my Android app and I want to change Actionbar text color and back button color.
This code is not working:
<style name="AppTheme" parent="Theme.MaterialComponents.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:windowContentOverlay">@null</item>
<!--<item name="android:textSize">3sp</item>-->
<item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/titleColor</item>
</style>
答案1
得分: 9
使用主题中的ActionBar
,您可以使用以下代码:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="actionBarTheme">@style/ThemeOverlay.Actionbar</item>
</style>
<style name="ThemeOverlay.Actionbar" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar">
<item name="android:textColorPrimary">@color/....</item>
</style>
英文:
Using the ActionBar
in your theme you can use:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="actionBarTheme">@style/ThemeOverlay.Actionbar</item>
</style>
<style name="ThemeOverlay.Actionbar" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" >
<item name="android:textColorPrimary">@color/....</item>
</style>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论