如何更改选项卡标题背景的颜色?标准颜色是蓝色。我怎样才能把它变成白色?喜欢这里:https://www.androidpolice.com/wp-content/uploads/2014/10/nexus2cee_43.png
最佳答案
自定义默认主题
例如,您的 styles.xml 文件应类似于以下内容:
<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>
一旦你知道你的颜色,更新 res/values/colors.xml 中的值:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- color for the app bar and other primary UI elements -->
<color name="colorPrimary">#3F51B5</color>
<!-- a darker variant of the primary color, used for
the status bar (on Android 5.0+) and contextual app bars -->
<color name="colorPrimaryDark">#303F9F</color>
<!-- a secondary color for controls like checkboxes and text fields -->
<color name="colorAccent">#FF4081</color>
</resources>
覆盖你想要的任何其他样式
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="android:windowBackground">@color/activityBackground</item>
</style>
引自:https://developer.android.com/guide/topics/ui/look-and-feel/themes.html#CustomizeTheme
以编程方式:
您可以在AndroidManifest.xml 中调用方法并设置Theme。
<application
android:name=".Class.App"
android:icon="@mipmap/ic_test"
android:theme="@style/AppTheme" <-- Add your custom theme here
</application>
关于Java - 如何更改应用程序选项卡的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49541952/