我们如何在android中更改customactionbar的标题文本颜色?

时间:2015-06-15 08:27:28

标签: android android-actionbar android-styles custom-action

这是我的styles.xml文件。你能否告诉我如何更改操作栏的标题文字颜色?默认情况下,文本显示为黑色。

styles.xml

<!--
    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>

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background" >@color/MyColor</item>
    <item name="background">@color/MyColor</item>
</style>

<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">
    <item name="android:actionBarStyle" >@style/MyActionBar</item>
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

1 个答案:

答案 0 :(得分:1)

好的,我找到了更好的方法。我现在只能改变标题的颜色,你也可以调整副标题。

这是我的styles.xml

const KEY_FILE = '<<some location on server>>/xxx-65454f656a-xxx-560265d-privatekey.p12';
// this is my private key file location, make sure it accessible 


try {
            $key = file_get_contents(KEY_FILE);     
            $auth = new \Google_Auth_AssertionCredentials(
                    SERVICE_ACCOUNT_NAME,
                    array('https://www.googleapis.com/auth/calendar'),
                    $key);
            $auth->sub = $calendarId;
            $client = new \Google_Client();
            $client->setAssertionCredentials($auth);
            $client->setApplicationName("Parabola V2");
            $client->setClientId(CLIENT_ID);
            $service = new \Google_Service_Calendar($client);
            $service->events->delete($calendarId, $eventId);            
        } catch (\Exception $e) {
            echo "Exception while deleting event :- ".$e->getMessage();
            return null;
        }

<?xml version="1.0" encoding="utf-8"?>
<resources>

  <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<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 name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/red</item>