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>
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 generated a custom theme using the Android Asset Studio Actionbar styling tool. I am not able to view the theme. I only get the AppCompat.Light or AppCompat.Light.DarkActionBar base theme in my app. (I also referred to this article Theme not applied using appcompat library on some Android 4.X devices)
My values/styles.xml
<style name="Theme.Betbuds" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_betbuds</item>
<item name="popupMenuStyle">#style/PopupMenu.Betbuds</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Betbuds</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Betbuds</item>
<item name="actionDropDownStyle">#style/DropDownNav.Betbuds</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Betbuds</item>
<item name="actionModeBackground">#drawable/cab_background_top_betbuds</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_betbuds</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Betbuds</item>
</style>
<style name="ActionBar.Solid.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_betbuds</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_betbuds</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_betbuds</item>
<item name="progressBarStyle">#style/ProgressBar.Betbuds</item>
</style>
<style name="ActionBar.Transparent.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_betbuds</item>
<item name="progressBarStyle">#style/ProgressBar.Betbuds</item>
</style>
<style name="PopupMenu.Betbuds" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_betbuds</item>
</style>
<style name="DropDownListView.Betbuds" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_betbuds</item>
</style>
<style name="ActionBarTabStyle.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_betbuds</item>
</style>
<style name="DropDownNav.Betbuds" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_betbuds</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_betbuds</item>
<item name="android:dropDownSelector">#drawable/selectable_background_betbuds</item>
</style>
<style name="ProgressBar.Betbuds" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_betbuds</item>
</style>
<style name="ActionButton.CloseMode.Betbuds" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_betbuds</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Betbuds.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Betbuds</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Betbuds</item>
</style>
My values-v14/styles.xml
<style name="Theme.Betbuds" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_betbuds</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Betbuds</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Betbuds</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Betbuds</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Betbuds</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Betbuds</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_betbuds</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_betbuds</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Betbuds</item>
</style>
<style name="ActionBar.Solid.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_solid_betbuds</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_betbuds</item>
<item name="android:backgroundSplit">#drawable/ab_solid_betbuds</item>
<item name="android:progressBarStyle">#style/ProgressBar.Betbuds</item>
</style>
<style name="ActionBar.Transparent.Betbuds" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">#drawable/ab_transparent_betbuds</item>
<item name="android:progressBarStyle">#style/ProgressBar.Betbuds</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Betbuds.Widget" parent="#style/Theme.AppCompat">
<item name="android:popupMenuStyle">#style/PopupMenu.Betbuds</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Betbuds</item>
</style>
</resources>
The Android Studio preview also shows only the Base themes. I have the following in my Manifest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Betbuds" >
I realise that there are a lot of questions similar to this. I am not able to figure out an answer. Any help is appreciated. Thanks.
I want to change some colors of android UI elements. But I would prefer to set a default tint color, which applies to all UI elements. I am not sure if this is possible.
If not, I want to set the "tint"-color of some UI elements, as shown below. Can anybody enlighten me?
EDIT
Based on what Entreco suggested:
My styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:textColorPrimary">#color/brown</item>
<item name="android:textColorSecondary">#color/brown</item>
<item name="android:textColorTertiary">#color/brown</item>
<item name="android:textColorPrimaryInverse">#color/brown</item>
<item name="android:textColorSecondaryInverse">#color/brown</item>
<item name="android:textColorTertiaryInverse">#color/brown</item>
<item name="colorPrimary">#color/blue</item>
<item name="colorPrimaryDark">#color/blue</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:subtitleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:background">#color/brown</item>
<item name="titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="subtitleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="background">#color/brown</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/brown_light</item>
<item name="android:textSize">24sp</item>
</style>
</resources>
And my values-v21/styles.xml:
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">#color/blue</item>
<item name="android:colorPrimaryDark">#color/blue</item>
<!-- <item name="android:colorAccent">#color/white</item> -->
</style>
</resources>
And in my Manifest:
<application android:theme="#style/AppTheme.Base" >
...
</application>
But the primary color is still the same...???
Starting from Lollipop this is straight-forward thanks to the colorPrimary attribute:
file values/styles.xml:
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
</style>
file values-v21/styles.xml:
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<item name="android:colorAccent">#color/white</item>
</style>
Basically, you can define a color pallete for your app, and I believe for your case your want to set the colorPrimary (unverified).
More info on Material colors
I am having a problem preventing the status bar from taking on the primaryColor. I want to leave the status bar unstyled but on lollipop it is always taking on the color of the primaryColor defined in my styles.xml
Excerpt from styles:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="colorPrimaryDark">?attr/colorPrimary</item>
<item name="colorAccent">?attr/colorPrimary</item>
<item name="android:textColorPrimary">#android:color/primary_text_light</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme.TransparentActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">?attr/colorPrimary</item>
<item name="colorAccent">?attr/colorPrimary</item>
<item name="android:textColorPrimary">#android:color/primary_text_light</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
<item name="android:windowBackground">#color/white</item>
</style>
<!-- START Market Themes -->
<style name="AppTheme.Blue" parent="AppTheme">
<item name="colorPrimary">#color/primaryColorBlue</item>
</style>
styles/v21
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="colorPrimaryDark">?attr/colorPrimary</item>
<item name="colorAccent">?attr/colorPrimary</item>
<item name="android:textColorPrimary">#android:color/primary_text_light</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme.TransparentActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">?attr/colorPrimary</item>
<item name="colorAccent">?attr/colorPrimary</item>
<item name="android:textColorPrimary">#android:color/primary_text_light</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#color/black</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
<item name="android:windowBackground">#color/white</item>
<item name="android:windowContentTransitions">true</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#android:color/white</item>
</style>
<style name="ToolBarStyle" parent="">
<item name="android:elevation">#dimen/toolbar_elevation</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
You're telling it to be your primary colour.
The status bar gets its colour form your colorPrimaryDark so change
<item name="colorPrimaryDark">?attr/colorPrimary</item>
to
<item name="colorPrimary">?attr/colorPrimary</item>
<item name="colorPrimaryDark">#android:color/black</item>
I think this should only be necessary in your styles-v21 but I'm not close enough to anything to test it.
Docs here
<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>
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..