gpt4 book ai didi

android - 更改 Android 应用程序的 ActionBar 标题颜色

转载 作者:行者123 更新时间:2023-11-29 20:42:28 25 4
gpt4 key购买 nike

我已经阅读了所有已经提出的关于此的问题,但我仍然无法更改操作栏中文本的颜色。对于代码,我几乎复制/粘贴了以下链接中的说明: https://developer.android.com/training/basics/actionbar/styling.html#CustomText

<!--theme applied to the application or activity-->
<style name="myActionbarTheme" parent="android:Theme.Holo">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
<item name="android:actionMenuTextColor">@color/lightBlue</item>
</style>

<!-- actionBar styles -->
<style name="MyActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>

<!-- actionBar title text -->
<style name="MyActionBarTitleText" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/lightBlue</item>
<item name="android:textSize">16sp</item>

</style>

<!-- actionBar tabs text styles -->
<style name="MyActionBarTabText" parent="android:Widget.Holo.ActionBar.TabText">
<item name="android:textColor">@color/lightBlue</item>
</style>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

最后两种样式未使用,但它们可能会造成我不知道的冲突。这就是我在 styles.xml 中的内容,而对于 androidmanifest,代码是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flexenergy.swapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light" >
<activity
android:name="com.flexenergy.swapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<application
android:allowBackup="true"
android:theme="@style/myActionBarTheme">

</application>

最后是color.xml的代码:

<item name="lightBlue" type="color">#00FF00</item>
<integer-array name="androidcolors">
<item>@color/lightBlue</item>
</integer-array>

我在这方面是个新手,所以不要对应该正确的事情做出任何假设......

提前致谢。

最佳答案

更改 android:theme="@android:style/Theme.Holo.Light"在你的 list 中到 android:theme="@style/myActionbarTheme" , 并去掉毫无意义的秒 <application>元素。只有一个 <application>此时每个 Android list 中的元素。

关于android - 更改 Android 应用程序的 ActionBar 标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30821630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com