I want change the colour of the task bar i.e., The color of the very top of the line where the time and battery display etc. are located suppose to be dark gray instead of black. I have used
setTitleColor(color.darker_gray);
But, It did not get effect. can anyone help me.
Thanks in advance.
your can use this library :) it works only for kitkat + :)
update: the library name is : SystemBarTint in github.com
By Changing Theme
<style name="AppTheme" parent="android:Theme.Light">
....
<!--Changing windowBackground will let your status change the color in most of the device-->
<item name="android:windowBackground">YOUR_COLOR</item>
...
</style>
By Code
View view = this.getWindow().getDecorView();
view.setBackgroundColor(color);
You can define your custom theme for the app and set the action bar background there
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">ANY_HEX_COLOR_CODE</item>
</style>
</resources>
Then in your app manifest file set the theme to MyTheme
Related
I have tried many options but whatever I use, it seems I cannot change the toolbar or action bar color & styles in the 'style.xml' file. it seems like using 'android.support.v7.widget.toolbar' is my only option . do you know a way so that I can change action bar styles in 'style.xml' file?
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#style/ThemeOverlay.AppCompat.ActionBar">
<item name="android:background">#ff0000</item>
</style>
and in the manifest i used 'CustomActionBarTheme' as my default theme .
i found the solution , my first mistake was that i should use a theme like :
'Theme.AppCompat.Light' , anything that starts with Theme , and finally creating an style like bellow , with parent set to 'Widget.AppCompat.ActionBar'
<style name="customActionbarStyle" parent="Widget.AppCompat.ActionBar">
<item name="background">#color/your_custom_color</item>
// also notice you must use color.xml file for colors and for some attributes
// like titleTextStyle , you must define another style and use it here like :
<item name="titleTextStyle">#style/your_title_text_style</item>
</style>
<style name="your_title_text_style">
<item name="android:textColor">#color/your_text_color</item>
</style>
you can find all other properties of ActionBar bellow :
https://developer.android.com/reference/android/R.styleable.html#ActionBar
I am setting the theme of my app to MyTheme:
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#B87333</item>
</style>
but this doesn't seem to be working. I set the application theme to this one. The graphical layout is saying the actionbar is brown, but when I run the app, the color is not brown, but the holo.light style.
Use this in your MainActivities onCreate:
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xFF3F9FE0));
replace 0xFF3F9FE0 with your color code. the format is AARRGGBB
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?
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!
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.
I'm attempting to modify the theme for my application. I've been able to successfully set the background color for my app, and the background color for my action bar.
Unfortunately, the background color of the items WITHIN the action bar are taking the background color of the app, not the bg color of the action bar.
Here's my code from styles.xml
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:background">#ff0000</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#fefefe</item>
</style>
and here's a screenshot of what's happening.
Hoping I'm missing something stupid here...
Thanks!
I'm pretty sure your theme background is being applied to everything. Instead, you only want the activity's background to be that color. So instead of setting the background color in the theme, you should set it for the activity. If you have many activities that will use this background color, then create a style for your activities and apply it to each one.
Try using:
<item name="android:windowBackground">#color/your_color</item>
<item name="android:colorBackground">#color/your_color</item>
Worked for me.
Now I am working on a android app using actionbar sherlock and fragment.I used the following theme.
<style name="Theme.AndroidDevelopers" parent="Theme.Sherlock.ForceOverflow">
<item name="android:actionDropDownStyle">#style/MyDropDownNav</item>
<item name="actionDropDownStyle">#style/MyDropDownNav</item>
</style>
And I got the following Output.
But I want use the light theme so I changed the parent as
parent="Theme.Sherlock.Light.ForceOverflow"
Then I got the following output
The light theme is missing the blue underline. How can i make that blue underline?...Please help me friends.
You have to create you own theme in order to do that:
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">ANY_HEX_COLOR_CODE</item>
</style>
</resources>
As the Background you can then put a modified 9 patch Image with a blue underline. Look at your Android Sdk > API 13+ there should be the original Actionbar bavkground drawables. Just modify them and set it as background. Don't forget to set this Theme as your App theme later on.
Edit:
Here are some 9 Patch images from Jake Whartons Action Bar Sherlock(what a coincidence that he formated my post earlier...:) ):
Create your own style for action bar and override background property:
<style name="MyActionBarStyle" parent="Widget.Sherlock.Light.ActionBar.Solid">
<item name="android:background">#drawable/bg_action_bar</item>
<item name="background">#drawable/bg_action_bar</item>
</style>
Use this style for your action bar in theme:
<style name="Theme.AndroidDevelopers" parent="Theme.Sherlock.Light.ForceOverflow">
<item name="actionBarStyle">#style/MyActionBarStyle</item>
<item name="android:actionBarStyle">#style/MyActionBarStyle</item>
</style>
Take a look onto res\drawable-hdpi\abs__ab_transparent_light_holo.9.png drawable inside ActionBarSherlock sources how to create 9-patch drawable with color strip line at the bottom.