Support Actionbar Icon overlay ActionbarDivider - android

i try to fix a bug in my app.
In case of that i have to change my ActionBar to the SupportActionbar!
But now my icon overlays the divider.
And the TitleText is away can u help me?
Thank you!
Styles:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 11 theme customizations can go here. -->
<item name="android:actionBarStyle">#style/myActionBar</item>
<item name="android:background">#000000</item>
</style>
<style name="myActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/abc_ab_transparent_dark_holo</item>
<item name="android:textColor">#FFFFFF</item>
<item name="actionBarItemBackground">#android:color/transparent</item>
</style>

Related

Android ActionBar Background gets overridden by AppTheme Background

I just can't figure this one out:
I have an application with an ActionBar, I want the ActionBar to be red and the background of the app blue. I tried to achieve this with this styles.xml:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#color/blue</item>
<item name="background">#color/blue</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/red</item>
<item name="background">#color/red</item>
</style>
But the actionBar is always blue. When I take away the blue background of the app, the actionBar is red as desired...
Any ideas?
The margin that you set is ambiguous and does not apply to anything. You should set the margin on your action bar theme:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/red</item>
<item name="android:windowBackground">#color/blue</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:layout_marginTop">5dp</item>
</style>
If all you're trying to do is a red action bar with a blue background, it is much easier to use the material properties included with v21+ of the support library:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/red</item>
<item name="android:windowBackground">#color/blue</item>
</style>

Change actionbar background and title color

I am new to Android development. The app on which I am working requires white action bar background and the title should be black in color. I am using support library for lower compatibility.
Style.xml
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
How can I do this ?
Styles : Main App Theme
<style name="MyAppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/CustomActionBarStyle</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/CustomActionBarStyle</item>
</style>
Setup styles for text and background color
<style name="CustomActionBarStyle" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">#color/white</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<item name="background">#color/white</item>
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
</style>
Setup TextColor Impt: parent must #style/TextAppearance.AppCompat.Widget.ActionBar.Title
<style name="MyActionBarTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/action_bar_text_color</item>
</style>
For more refer links posted in #Santosh Shinde post
Use This to change title color
ActionBar actionBar = getActionBar();
actionBar.setTitle(Html
.fromHtml("<font color='#ffffff'> Now playing </font>"));
and for action bar title
getActionBar().setBackgroundDrawable(
new ColorDrawable(Color.rgb(0, 0, 0)));
or
getActionBar().setBackgroundDrawable(
new ColorDrawable(Color.parseColor("#000000")));
Try this style:
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="android:buttonStyle">#style/Button</item>
<item name="android:editTextStyle">#style/EditText</item>
<item name="android:windowBackground">#android:color/black</item>
</style>
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:backgroundStacked">#color/core_other_light</item>
<item name="android:backgroundSplit">#color/core_other</item>
<item name="android:background">#00ff00</item>
</style>
You can find more information here and here.

Android's Material Design of Toolbar / SupportActionBar

I'm experimenting with the news themes tonight and I'm wondering if anyone knows these fix to this issue.
This appears on the stock Toolbar and even, as seen below, when referring to custom layout file.
It's relatively minor but my OCD eyes go right to it so maybe someone can help. Thanks :)
UPDATE: Inheriting from the correct theme and declaring attributes in pairs (with and without the android: prefix) was the fix!
<!-- Base app theme. -->
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles. -->
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
<item name="android:subtitleTextStyle">#style/MyActionBarSubTitleText</item>
<item name="subtitleTextStyle">#style/MyActionBarSubTitleText</item>
<item name="android:background">#color/blue</item>
<item name="background">#color/blue</item>
</style>
<style name="MyActionBarTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
<style name="MyActionBarSubTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">#dimen/subtitle</item>
</style>
If es0329's answer doesn't work for you, try to replace titleTextStyle by titleTextAppearance. It is working for me:
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar">
<item name="android:titleTextAppearance">#style/MyActionBarTitleText</item>
<item name="titleTextAppearance">#style/MyActionBarTitleText</item>
<item name="android:subtitleTextAppearance">#style/MyActionBarSubTitleText</item>
<item name="subtitleTextAppearance">#style/MyActionBarSubTitleText</item>
<item name="android:background">#color/blue</item>
<item name="background">#color/blue</item>
</style>

Android Flat ActionBar (without shadow)

i'm trying to create the a flat action bar without shadow
attached image:
my style xml
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:background">#drawable/white_bg</item>
<item name="android:displayOptions"></item>
</style>
I'm supporting android 4.x
Any ideas ? I tried changing the style to Solid/Inverse didn't work..
white_bg attached (It's hard to see since it's white)
it should look like this
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:background">#drawable/white_bg</item>
<item name="android:displayOptions"></item>
</style>
The null windowContentOverlay attribute should be set on your Activity theme (CustomActionBarTheme), not on the ActionBar theme.

Home Icon Up Indicator Compat Action Bar

I'm trying to change the "up" indicator, I've implemented the new compat action bar and I'm not able to customize it.
I've tried adding to values-v11/styles.xml
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:icon">#drawable/ic_action_logo_barra_de_acciones_blanco</item>
<item name="android:background">#drawable/action_bar_style</item>
<item name="android:homeAsUpIndicator">#drawable/arrow_up_black</item>
</style>
and to values/styles.xml
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/action_bar_style</item>
<item name="icon">#drawable/ic_action_logo_barra_de_acciones_blanco</item>
<item name="homeAsUpIndicator">#drawable/arrow_up_black</item>
</style>
But is still not working.
Thanks in advance, Diego.
Sorry, maybe already late, but I had same issue and solved it by defining "homeAsUpIndicator" in main theme before ActionBar style.
Here is my res/values/styles.xml
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="homeAsUpIndicator">#drawable/abc_ic_ab_back_holo_dark</item>
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/messages_form_banner</item>
</style>
I hope it will help you.

Categories

Resources