Title do not appear on android action bar - android

I am trying to style my actionbar with background color. I have also given label in the android manifest file which shows up in the action bar. But when i try to change background color using Style.xml , it changes the background color but do not show label.
Below is the Style xml
<style name="AppBaseTheme" parent="Theme.AppCompat.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. -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="background">#color/actionbarcolor</item>
</style>
could you please let me know , what change i should make so that it shows label name also after applying background color.
I have applied theme "AppTheme" at application level in manifest file .

Try to add this
<style>
<item name="android:actionBarTabTextStyle">#style/AwesomeTabTextStyle</item>
</style>
<style name="AwesomeTabTextStyle" parent="#android:style/Widget.ActionBar.TabText">
<item name="android:textAppearance">#android:style/TextAppearance.Medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">#color/actionbar_text_color</item>
</style>

Related

Color "splitActionBarWhenNarrow" Bottom Action Bar

I have an MainActivity extends ActionBarActivity , I want to color my action bar I used a custom style , the problem that the custom styles I'm using requires Api 11 At least I tried using:
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0099cc")));
But the Bottom ActionBar is Not Colored
This Is My Style.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="Theme.AppCompat.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>
If you want to color your split action bar u will have to use android:backgroundSplit. following code will help you.
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#9933CC</item>
<item name="android:backgroundSplit">#9933CC</item>
<item name="android:titleTextStyle">#style/myTheme.ActionBar.Text</item>
</style>
<style name="myTheme.ActionBar.Text" parent="#android:style/TextAppearance">
<item name="android:textColor">#FFFFFF</item>
<item name="android:typeface">monospace</item>
<item name="android:textStyle">bold</item>
</style>

Testing ActionBar Background Color

I am starting to unit testing my Android code. However, I am facing a problem of how to test the background of ActionBar. I set the action bar color using the following:
<style name="AppBaseTheme" parent="android:Theme.Light">
<item name="android:actionBarStyle">#style/ActionBarTheme</item>
</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="ActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/dark_green</item>
</style>
So, how to load the style in code and check for the background color so I can test it?
In your application manifest make sure you have android:theme="#style/AppBaseTheme"
Or whatever you decide to name your custom theme.

Set custom style and action bar

I'm developing an app that needs to work with action bar and tab bar, my first issue was to set up a custom text style for the label on the tab bar, now I want to use the action bar, but I'm having trouble with custom style and action bar. I made a custom style so:
styles.xml
<resources>
<!--
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="CustomTheme" parent="#android:style/Theme">
<item name="android:tabWidgetStyle">#style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="#android:style/Widget.TabWidget">
<item name="android:textAppearance">#style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" parent="#android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">10sp</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
Now I read here that I can add an action bar to a custom style, so i tried to do so:
styles.xml
<resources>
<!--
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="CustomTheme" parent="#android:style/Theme">
<item name="android:tabWidgetStyle">#style/CustomTabWidget</item>
<item name="android:actionBarStyle">#style/Widget.ActionBar</item>
</style>
<style name="CustomTabWidget" parent="#android:style/Widget.TabWidget">
<item name="android:textAppearance">#style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" parent="#android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">10sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="Widget.ActionBar" parent="android:Widget.Holo.Light.ActionBar">
<item name="android:displayOptions">showHome|useLogo|showCustom</item>
<item name="android:customNavigationLayout">#layout/custom</item>
</style>
</resources>
If you look at my xml code you can see that I add the Widget.ActionBar style to display an action bar on my activity. When I try to run my app I can see the custom style for the tab host, but I can't see the action bar.
I need action bar to put there a the share button.
Can you help me?
Have you try this?
Here it given to make actionbarserlock.

android 3.0+ action bar keep background when styling

I'm developing an App for Android 3.0+ and I want to personalize the action bar by removing the title, which I can accomplish, my problem is that I also lose the background on the action bar, I would just like to remove the title and keep the remaining style. Here's what I'm currently using:
<resources>
<!--
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. -->
<item name="android:actionBarStyle">#style/ActionBarNoTitle</item>
</style>
<style name="ActionBarNoTitle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showHome|useLogo</item>
</style>
</resources>
I'd prefer not to change the Activity code to accomplish this.
Which theme are you using? That is probably defined in values-v11 or values-v14. If Theme.Holo.Light you have to change the actionBarStyle's parent style to Widget.Holo.Light.ActionBar.Solid.
<style name="ActionBarNoTitle" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions">showHome|useLogo</item>
</style>
Did you try this,
define this in your theme.xml file,
<style name="CustomActionBar" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/CustomActionBarStyle</item>
</style>
define this in your style.xml file,
<style name="CustomActionBarStyle" parent="android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">#style/NoTitleText</item>
<item name="android:subtitleTextStyle">#style/NoTitleText</item>
</style>
<style name="NoTitleText">
<item name="android:textSize">0sp</item>
<item name="android:textColor">#00000000</item>
</style>
Let me know if this works.

ActionBar title color does not change

I want to change the title color of actionbar to white. I have declared on styles:
<!--
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.Holo.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. -->
<item name="android:windowActionBar">true</item>
<item name="android:actionBarStyle">#style/ProjActionBar</item>
<item name="android:actionBarTabTextStyle">#style/ProjActionBar.TitleTextStyle</item>
</style>
<!-- ActionBar Style -->
<style name="ProjActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/b</item>
<item name="android:backgroundStacked">#color/k1</item>
<!-- This is when tabs are splitted into a second line -->
</style>
<style name="ProjActionBar.TitleTextStyle" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/w</item>
<item name="android:textSize">13sp</item>
</style>
As you can see I have a "actionBarTabTextStyle" declared with the attribute "textColor" to #color/w declared in my colors.xml as:
<color name="w">#FFFFFFFF</color>
What happend? why the actionbar title does not change textColor?
My project is targeted to min SDK 11 sdkVersion 17 (Honeycomb 3.0+)
The problem is that you have not actually changed the title text style. You have changed the style of the tab text. To change the title text style, you want to set android:titleTextStyle and optionally android:subtitleTextStyle on your ProjActionBar style.
So, your ProjActionBar becomes this:
<style name="ProjActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/b</item>
<item name="android:backgroundStacked">#color/k1</item>
<item name="android:titleTextStyle">#style/ProjActionBar.TitleTextStyle</item>
</style>
Please note that this assumes you are using the native ActionBar components (as indicated by the fact that you are inheriting from #android:style/Widget.Holo.Light.ActionBar). If you want backwards compatibility, you will have to inherit your style from Widget.AppCompat.Light.ActionBar and use textStyle instead of android:textStyle.

Categories

Resources