I'm using ActionBarSherlock, and my app will install on many kinds of smartphones, and for the small smartphones I divide the actionbar with:
android:uiOptions="splitActionBarWhenNarrow"
My problem appear when the bar is split, because the style only is maintained on the top bar (green), but not on the button bar (gray) :P
Here a screenshot:
And my current style:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
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="Theme.Sherlock.Light">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:textViewStyle">#style/label</item>
<item name="android:checkboxStyle">#style/checkbox</item>
<item name="android:buttonStyle">#style/boton</item>
<item name="android:starStyle">#style/star</item>
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<!-- Agregamos algunos estilos para ver como cambiar los colores de la barra -->
<item name="android:actionDropDownStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionDropDownStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionBarSplitStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarSplitStyle">#style/Widget.Styled.ActionBar</item>
</style>
<style name="label" parent="android:style/Widget.TextView">
<item name="android:padding">4dp</item>
<item name="android:textColor">#DF0101</item>
<item name="android:textSize">20sp</item>
</style>
<style name="checkbox" parent="android:style/Widget.CompoundButton.CheckBox">
<item name="android:textColor">#DF0101</item>
<item name="android:textSize">20sp</item>
</style>
<style name="boton" parent="android:style/Widget.Button">
<item name="android:background">#drawable/btn_form</item>
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">20sp</item>
</style>
<style name="star" parent="android:style/Widget.CompoundButton.Star">
<item name="android:textColor">#DF0101</item>
<item name="android:textSize">20sp</item>
</style>
<style name="Widget.Styled.ActionBar"
parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/background</item>
<item name="android:background">#drawable/background</item>
<item name="android:backgroundStacked">#drawable/background</item>
<item name="android:backgroundSplit">#drawable/background</item>
<item name="android:actionButtonStyle">#drawable/background</item>
</style>
</resources>
What is the name of this component, in order to add it to the style sheet?
My problem was I forgot to put this parameter:
<item name="backgroundSplit">#drawable/background</item>
Only had placed this:
<item name="android:backgroundSplit">#drawable/bg_actionbar</item>
Sorry :P
Related
I am trying to change my App ActionBar colour to no success. I am using the this library https://github.com/neokree/MaterialNavigationDrawer;
Here is the style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
<item name="colorControlActivated">#color/color_c</item>
<item name="toolbarStyle">#style/Widget.Toolbar</item>
</style>
<style name="Widget.Toolbar" parent="#style/Widget.AppCompat.Toolbar">
<item name="contentInsetStart">5dp</item>
</style>
<style name="AppTheme.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/color_a</item>
<item name="background">#color/color_a</item>
<!-- Support library compatibility -->
</style>
<style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#null</item>
</style>
<style name="MyNavigationDrawerTheme" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar">
<item name="colorPrimary">#color/color_a</item>
<item name="colorPrimaryDark">#color/color_a</item>
<item name="colorAccent">#FFFFFF</item>
<item name="rippleBackport">true</item>
<item name="singleAccount">true</item>
<item name="multipaneSupport">true</item>
<!--<item name="learningPattern">false</item>-->
</style>
<style name="MySubheaderTheme">
<item name="subheaderTitleColor">#000000</item>
</style>
<style name="MySectionTheme" >
<item name="sectionColorIcon">#000000</item>
<item name="sectionColorText">#000000</item>
<item name="sectionColorNotification">#000000</item>
<item name="sectionBackgroundColorPressed">#160000FF</item>
<item name="sectionBackgroundColorSelected">#0A0000FF</item>
<item name="sectionBackgroundColor">#000000FF</item>
</style>
</resources>
I use the MyNavigationDrawerTheme theme for my activities.
You should be able to set the action bar color using the android:colorPrimary attribute:
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">#color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">#color/accent</item>
</style>
</resources>
Based on information here
You should create your styles also for v21 and above with a small change (because they natively support material theme).
And in values-v21/style.xml add android:colorPrimary and others attributes with android: prefix to your style:
<style name="MyNavigationDrawerTheme" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar">
<item name="android:colorPrimary">#color/color_a</item>
<item name="android:colorPrimaryDark">#color/color_a</item>
<item name="android:colorAccent">#FFFFFF</item>
<!--...-->
</style>
I'm currently having the following problem. I changed the default style of the application, my styles.xml looks like this
<!--
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.NoActionBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<item name="android:editTextColor">#000000</item>
<item name="android:textColor">#000000</item>
<item name="android:colorBackground">#ffffff</item>
<item name="android:spinnerItemStyle">#style/menu_spinner</item>
<item name="android:spinnerDropDownItemStyle">#style/menu_spinner</item>
<item name="android:windowBackground">#color/white</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:editTextColor">#000000</item>
<item name="android:editTextStyle">#style/App_EditTextStyle</item>
<item name="android:textColor">#000000</item>
<item name="android:alertDialogStyle">#style/CustomAlertDialogStyle</item>
<item name="android:colorBackground">#ffffff</item>
<item name="android:spinnerItemStyle">#style/menu_spinner</item>
<item name="android:spinnerDropDownItemStyle">#style/menu_spinner</item>
<item name="android:textColorSecondary">#color/white</item>
<item name="android:textColorTertiary">#ffffff</item>
<item name="android:windowBackground">#color/white</item>
</style>
<style name="CustomAlertDialogStyle">
<item name="android:windowBackground">#color/white</item>
<item name="android:bottomBright">#color/white</item>
<item name="android:bottomDark">#color/white</item>
<item name="android:bottomMedium">#color/white</item>
<item name="android:centerBright">#color/white</item>
<item name="android:centerDark">#color/white</item>
<item name="android:centerMedium">#color/white</item>
<item name="android:fullBright">#color/white</item>
<item name="android:fullDark">#color/white</item>
<item name="android:topBright">#color/white</item>
<item name="android:topDark">#color/white</item>
</style>
<style name="App_EditTextStyle" parent="#android:style/Widget.EditText">
<item name="android:textColor">#color/black</item>
</style>
<style name="LoginFormContainer" parent="AppBaseTheme">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">16dp</item>
</style>
<style name="menu_spinner">
<item name="android:textColor">#ffffff</item>
</style>
<style name="spinner_style" parent="AppBaseTheme">
<item name="android:textColor">#000000</item>
<item name="android:background">#drawable/spinner_bg</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
</style>
<style name="Widget.Holo.Light.CompoundButton.CheckBox" parent="Widget.Holo.CompoundButton.CheckBox" />
<style name="Widget.Holo.CompoundButton.CheckBox" parent="Widget.Holo.CompoundButton.CheckBox" />
However, all my dialogs show a darker background, I don't understand why they do not have white background, as I've defined the properties windowbackground and colorbackground by default as white. Here's how a progressdialog looks like by default:
In my AndroidManifest, the theme is "AppTheme":
<application
android:name="com.activeandroid.app.Application"
android:allowBackup="true"
android:icon="#drawable/icono_grande"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
....
</application>
If you want to change the theme for Dialog Specific, you could try something like this:
<!-- Makes a "light" equivalent of Theme.Dialog -->
<style name="dialog_light" parent="#android:style/Theme.Light.Dialog">
<item name="#android:background">#android:color/background_light</item>
<!-- Whatever you want to add here -->
</style>
If it is App wide, then something like this should do:
<!-- Makes a "light" equivalent of Theme.Dialog -->
<style name="popup_theme" parent="#android:style/Theme.Light">
<item name="android:windowBackground">#color/back_color</item>
<item name="android:colorBackground">#color/back_color</item>
<!-- Whatever you want to add here -->
</style>
I am using AppCompat Library.
in values/styles.xml I am using the following code
<!--
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. -->
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/CLActionBar</item>
<item name="actionBarStyle">#style/CLActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="CLActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background" tools:ignore="NewApi">#color/actionbar_bg_color</item>
<item name="android:textColor" tools:ignore="NewApi">#color/actionbar_txt_color</item>
<item name="android:subtitleTextStyle" tools:ignore="NewApi">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="background" >#color/actionbar_bg_color</item>
<!--<item name="textColor" >#color/actionbar_txt_color</item>-->
<item name="subtitleTextStyle" >#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
<item name="android:textColor" tools:ignore="NewApi">#color/actionbar_txt_color</item>
<!--<item name="textColor">#color/actionbar_txt_color</item>-->
</style>
in values-v21/styles.xml
<!– Base application theme. –>
<style name="AppTheme" parent="#android:style/Theme.Material.Light.DarkActionBar">
<!– Customize your theme here. –>
</style>
-->
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/CLActionBar</item>
<item name="actionBarStyle">#style/CLActionBar</item>
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
<!--<item name="android:windowContentTransitions">true</item>-->
<!--<item name="android:windowAllowEnterTransitionOverlap">true</item>-->
<!--<item name="android:windowAllowReturnTransitionOverlap">true</item>-->
<!--<item name="android:windowSharedElementEnterTransition">#android:transition/move</item>-->
<!--<item name="android:windowSharedElementExitTransition">#android:transition/move</item>-->
</style>
<!-- ActionBar styles -->
<style name="CLActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background" tools:ignore="NewApi">#color/actionbar_bg_color</item>
<item name="android:textColor" tools:ignore="NewApi">#color/actionbar_txt_color</item>
<item name="android:subtitleTextStyle" tools:ignore="NewApi">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="background" >#color/actionbar_bg_color</item>
<!--<item name="textColor" >#color/actionbar_txt_color</item>-->
<item name="subtitleTextStyle" >#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
<item name="android:textColor" tools:ignore="NewApi">#color/actionbar_txt_color</item>
<!--<item name="textColor">#color/actionbar_txt_color</item>-->
</style>
now when i try to set title to actionbar using getSupportActionBar.setTitle the title does not appear.
Please help
I solved the issue
I was using Theme.AppCompat.Light as app theme and #android:style/Widget.Holo.Light.ActionBar.Solid.Inverse" as actionbar theme. Changed this to
#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse and the issue is fixed.
Thanks
paste the below lines in value folder
<style name="MYBaseTheame" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/Widget.MYTheame.ActionBar</item>
</style>
<style name="MYTheame" parent="#style/MYBaseTheame">
<item name="android:windowBackground">#color/app_bg</item>
<item name="android:tabWidgetStyle">#android:style/Widget.TabWidget</item>
</style>
<style name="MYTheame.NoTittle" parent="#style/MYTheame">
<item name="android:windowNoTitle">true</item>
</style>
<style name="Widget.MYTheame.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="titleTextStyle">#style/TextAppearance.MYTheame.Widget.ActionBar.Title</item>
<item name="background">#color/ab_bg</item>
</style>
And Paste the below lines to value-14 folder
<style name="MYBaseTheame" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/Widget.MYTheame.ActionBar</item>
</style>
<style name="Widget.MYTheame.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:titleTextStyle">#style/TextAppearance.MYTheame.Widget.ActionBar.Title</item>
<item name="android:background">#color/ab_bg</item>
</style>
I try to develop an app for API 8 but do not have any experience with styles.xml. For activities in the app I use Theme.Light. After playing with styles I got the error above. I've also checked other posts on this portal and I tried many suggestions but I could not get further. The styles.xml is below and hopefully someone will come with suggestions.
<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="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>
<style name="ContactLabelTextView">
<item name="layout_width">wrap_content</item>
<item name="layout_height">wrap_content</item>
<item name="layout_gravity">left|center_vertical</item>
<item name="layout_marginLeft">15dp</item>
<item name="layout_marginRight">5dp</item>
<item name="layout_marginTop">5dp</item>
<item name="clickable">false</item>
<item name="longClickable">false</item>
<item name="textSize">14sp</item>
<item name="textAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:textColor">#android:color/black</item>
<item name="layout_marginBottom">5dp</item>
</style>
<style name="ContactMultiplineText" >
<item name="layout_width">match_parent</item>
<item name="layout_height">wrap_content</item>
<item name="layout_marginLeft">15dp</item>
</style>
After reading the post recommended by Alexander Zhak I have better understanding of styles. Therefore, I made some modifications to my styles.xml and it works. Those modifications are:
...
<style name="ContactLabelTextView" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">14sp</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:longClickable">false</item>
<item name="android:clickable">false</item>
</style>
<style name="ContactLabelTextView.Layout">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">left|center_vertical</item>
<item name="android:layout_marginLeft">15dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginBottom">5dp</item>
</style>
<style name="ContactMultiplineText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">15dp</item>
</style>
...
You need to have a parent style to enable you to call the attributes of it.
sample:
<style name="ContactLabelTextView" parent="#android:style/TextAppearance.Medium">
The above code is used when you want your textView as a Medium size text, you can still change it what ever size you want for your TextView.
i want to remove default highlight of item selection in Android ActionBar, im using AppCompat
i try to set android:selectableItemBackground to transparent by seting color, or transparent shape or event drawable transparent png but no success
<style name="NActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
<item name="android:titleTextStyle">#android:color/white</item>
<item name="android:selectableItemBackground">#android:color/transparent</item>
<item name="android:background">#drawable/ab_transparent_example</item>
</style>
[EDIT]
style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
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>
<style name="NTheme" parent="AppBaseTheme">
<item name="android:windowContentOverlay">#null</item>
<item name="android:buttonStyle">#style/NButton</item>
<item name="android:editTextStyle">#style/NEditText</item>
<item name="android:actionBarStyle">#style/NActionBar</item>
</style>
<style name="NThemeNoActionBar" parent="NTheme">
<item name="android:windowActionBar">false</item>
</style>
<style name="NButton" parent="android:style/Widget.Button">
<item name="android:background">#drawable/big_button</item>
<item name="android:textColor">#android:color/white</item>
</style>
<style name="NSmallButton" parent="android:style/Widget.Button">
<item name="android:background">#drawable/small_button</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:textSize">10sp</item>
</style>
<style name="NEditText" parent="android:style/Widget.EditText">
<item name="android:background">#android:color/transparent</item>
<item name="android:textColor">#color/blue</item>
<item name="android:textColorHint">#color/blue</item>
</style>
<!-- ActionBar styles -->
<style name="NActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
<item name="android:titleTextStyle">#android:color/white</item>
<item name="android:selectableItemBackground">#android:color/transparent</item>
<item name="android:background">#drawable/ab_transparent_example</item>
</style>
<style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">#style/ButtonBar</item>
<item name="metaButtonBarButtonStyle">#style/ButtonBarButton</item>
</style>
<style name="ButtonBar">
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingRight">2dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:background">#android:drawable/bottom_bar</item>
</style>
<style name="ButtonBarButton" />
<style name="FullHeightDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFrame">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
The actionBarItemBackground theme attribute will allow you to change the action item selector.
If you're using it with ActionBarSherlock or ActionBarCompat, be sure to provide an entry with and without the android: prefix.
In your style you can use below lines:
<item name="android:actionBarItemBackground">#drawable/my_drawable</item>
<item name="actionBarItemBackground">#drawable/my_drawable</item>
Hope it will help you..