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>
Related
I got this styles for my Android app:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowBackground">#color/background_new</item>
<item name="android:textColorPrimary">#color/colorAccent</item>
<item name="android:textColorHint">#color/colorAccentHint</item>
<!-- Customize your theme here. -->
</style>
<style name="MyToolBar" parent="Widget.AppCompat.ActionBar">
<!-- Support library compatibility -->
<item name="android:textColorPrimary">#color/colorAccent</item>
<item name="android:textColorSecondary">#color/colorAccent</item>
<item name="colorControlNormal">#color/colorAccent</item>
</style>
<!-- Custom searchView may be used or not-->
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
<!-- Gets rid of the search icon -->
<item name="searchIcon">#null</item>
<!-- Gets rid of the "underline" in the text -->
<item name="queryBackground">#null</item>
<!-- Gets rid of the search icon when the SearchView is expanded -->
<item name="searchHintIcon">#null</item>
<!-- The hint text that appears when the user has not typed anything -->
<!--<item name="closeIcon">#null</item> -->
</style>
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
<item name="tabTextAppearance">#style/MyCustomTabText</item>
</style>
<style name="MyCustomTabText" parent="TextAppearance.Design.Tab">
<item name="android:textSize">12sp</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="NavDrawerTextStyle" parent="Base.TextAppearance.AppCompat">
<item name="android:textSize">12sp</item>
</style>
<style name="MyCheckBox" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorControlNormal">#color/colorPrimaryTransparent</item>
<item name="colorControlActivated">#color/colorAccent</item>
</style>
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/colorAccent</item>
<item name="android:background">#color/background1</item>
<item name="android:buttonStyle">#style/MyApp.BorderlessButton</item>
</style>
<style name="MyApp.BorderlessButton" parent="#style/Widget.AppCompat.Button.Borderless">
<item name="android:textSize">12sp</item>
</style>
<style name="MyRadioButton" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">#color/colorAccent</item>
<item name="colorControlActivated">#color/colorAccent</item>
</style>
Normally i have transparent background on Toolbar of NavigationDrawler menu items click.
But sometimes theme in my app changes to Holo theme , and i can figure it out when its happens , so when i press menu items in Toolbar or in NavigationDrawler their background become blue, like in Holo theme
Where i have mistake and why its happens?
Can you publish your Android Manifest ? Maybe some activities override the base application 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 unable to change the text color of title of Action Bar. How can it be done in xml itself?
My style.xml in values-v11 and values-v14 contain this snippet of code
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBarStyle</item>
</style>
<style name="MyActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showTitle</item>
<item name="titleTextStyle">#style/titleStyle</item>
</style>
<style name="titleStyle" parent="#style/TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
<item name="android:textColor">#f2dca9</item>
</style>
</resources>
please try this. it works
you, put this code in the onCreate() method
ActionBar bar = getActionBar();
bar.setTitle(Html.fromHtml("<font color='#ff0000'>ActionBartitle </font>"));
or Add it to the root of the action bar
<style name="ActionBar" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionMenuTextColor">#color/stdDarkBlueText</item>
</style>
<style name="Widget.Styled.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="titleTextStyle">#style/ActionBarTitleText</item>
<item name="subtitleTextStyle">#style/ActionBarSubTitleText</item>
</style>
<style name="ActionBarTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/stdDarkBlueText</item>
<item name="android:textSize">12sp</item>
</style>
<style name="ActionBarSubTitleText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
<item name="android:textColor">#color/stdDarkBlueText</item>
<item name="android:textSize">12sp</item>
try this
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar">
<item name="android:displayOptions">showTitle</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#f2dca9</item>
</style>
Do it programmatically,
int titleId = this.activity.getResources().getIdentifier("action_bar_title", "id", "android");
TextView abTitle = (TextView) this.activity.findViewById(titleId);
abTitle.setTextColor(Color.parseColor("#6f6f6f"));
using XML:
<resources>
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:titleTextStyle">#style/TitleBarTextColor</item>
</style>
<style name="TitleBarTextColor" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
if you use API 14 and UP then put it into values-v14.....
Thats it...
I am having trouble finding out why the title in my action bar appears black, this only happens on an emulator with Android 4.1.1, which should be API 15.
Here is my default styles.xml
<resources>
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
and here is the styles from values-v15 and values-v14
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:actionOverflowButtonStyle">#style/OverFlow</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- Styles -->
<style name="OverFlow" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/ic_action_about</item>
<item name="android:textColor">#color/white</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/action_bar_background</item>
<item name="android:textColor">#color/white</item>
</style>
what would be the problem?
Try this:
<style name="TitleTextColor">
<item name="android:text">#string/app_name</item>
<item name="android:textSize">10sp</item>
<item name="android:textColor">#a23421</item>
</style>
Edit:(new) Put this in the styles.XML
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle"parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
</resources>
For White text:
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#f00</item>
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>
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..