Ryan Sayles
Ryan Sayles

Reputation: 3431

Android custom theme

Hello I'm making a custom theme for my app. I want to have a custom ActionBar and background for the rest of the app (below the ActionBar). I'm wondering how to do the background. Right now I have:

<style name="MyTheme" parent="android:Theme.Holo">
    <item name="android:actionBarStyle">@style/dActionBar</item>
</style>

<style name="dActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">#4C721D</item>
    <item name="android:textColor">#FFFFFF</item>    
</style>

Would I just have to do <item name-"android:background"></item> in MyTheme or would I have to create another style? After I create this do I need to put it in the res/styles folder? Also what are the API restrictions on this, if any?

Upvotes: 2

Views: 5233

Answers (2)

AMI CHARADAVA
AMI CHARADAVA

Reputation: 313

Try to use below code in your Style.xml file

<resources>
    <style name="Theme.Sample" parent="Theme.AppCompat">

   <item name="android:colorBackground">@color/primary_material_dark</item>
   <item name="actionBarTheme">@color/colorGray</item>
   </style>
</resources>

Just need to use android:colorBackground as a name of item to define the background color like as below:

    <item name="android:colorBackground">@color/primary_material_dark</item>

Hope you get your answer,Thanks.

Upvotes: 1

Jelle
Jelle

Reputation: 919

Don't forget to apply your theme to your application in your AndroidManifest.xml.

<application android:theme="@style/CustomActivityTheme" ... />

You can find all the information about styling the Actionbar here.

To style your ActionBar with a nice Holo-look, try this website

Hope this helps!

Upvotes: 1

Related Questions