1

I am trying to Style my Android app through styles and I cannot get action bar to update.

I am using v7 support package all my activities extend AppCompatActivity.

The actionBar works. but I cannot seem to style it at all. When I try to set the background of the Application. I will end up changing the background of the Action Bar.

styles.xml

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

<style name="Bea_Theme.ActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:background">@color/colorPrimary</item>
    <item name="android:textColor">#FF0000</item>
</style>

AndroidManifest.xml

<application
    android:name=".CallBellApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/Bea_Theme">
    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />

            <category android:name="com.example.gcm" />
        </intent-filter>
    </receiver>

    <service
        android:name=".service.CallBellGCMListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>
    <service
        android:name=".service.CallBellInstanceIdListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>
    <service
        android:name=".service.RegistrationIntentService"
        android:exported="false" >
    </service>

    <activity
        android:name=".presentation.login.LoginActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.MONKEY" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>


    <activity
        android:name=".presentation.bed.BedModeActivity"
        android:label="@string/title_activity_bed_mode">
    </activity>
    <activity android:name=".presentation.BaseActivity">

    </activity>
    <activity android:name=".presentation.station.StationActivity">
    </activity>
</application>

Results in just the plain old android applicationApplication Screenshot

1 Answer 1

0

You should be using colorPrimary directly in your theme to color your action bar as per this pro-tip:

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/primary</item>
</style>
2
  • This only works if I don't add "android:background". when I do. It sets both the background of the Activity and the Action Bar to that color. Is there a way to separate that?
    – austin
    Commented Oct 18, 2015 at 19:22
  • Also, if this is true, what do we set to change the Text color of the Action bar?
    – austin
    Commented Oct 18, 2015 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.