can´t change alert dialog theme in Sherlock ActionBar - android

I have a Sherlock Action Bar with Theme DarkActionBar so I can get the white search Icon in the Action Bar.
But, when I did that the submenu of my contextMenu (that is decided with a popUp - like an AlertDialog) the theme of this dialog is being dark like its parent, and I want it Light.
How should I do that? Get the white search icon (dark theme) and the Light theme for the context menu option ?
This is my styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="StyledIndicators" parent="#style/Theme.SherlockCustom">
<item name="vpiTabPageIndicatorStyle">#style/CustomTabPageIndicator</item>
<item name="vpiTabTextStyle">#style/CustomTabPageIndicator.Text</item>
</style>
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:background">#drawable/custom_tab_indicator</item>
</style>
<style name="CustomTabPageIndicator.Text" parent="Widget.TabPageIndicator.Text">
<item name="android:textColor">#FF555555</item>
</style>
<style name="CustomTheme.TitleActionBar" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="CustomTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar">
<item name="background">#drawable/gradiente_titlebar</item>
<item name="android:background">#drawable/gradiente_titlebar</item>
<item name="titleTextStyle">#style/CustomTheme.TitleActionBar</item>
<item name="android:titleTextStyle">#style/CustomTheme.TitleActionBar</item>
</style>
<style name="Theme.SherlockCustom" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/CustomTheme.ActionBarStyle</item>
<item name="android:actionBarStyle">#style/CustomTheme.ActionBarStyle</item>
<item name="spinnerDropDownItemStyle">#style/Theme.Sherlock.Light</item>
<item name="android:spinnerDropDownItemStyle">#style/Theme.Sherlock.Light</item>
<item name="spinnerItemStyle">#style/Theme.Sherlock.Light</item>
<item name="android:spinnerItemStyle">#style/Theme.Sherlock.Light</item>
<item name="popupMenuStyle">#style/Theme.Sherlock.Light</item>
<item name="android:popupMenuStyle">#style/Theme.Sherlock.Light</item>
<item name="actionDropDownStyle">#style/Theme.Sherlock.Light</item>
<item name="android:actionDropDownStyle">#style/Theme.Sherlock.Light</item>
<item name="android:alertDialogStyle">#style/Theme.Sherlock.Light</item>
</style>
</resources>

Found the answer at https://stackoverflow.com/a/15219098/1574617.
Just added that to code so now I can decide which widget search I want to use.
Thanks ASP for answer.
<style name = "Theme.SherlockCustom" parent = "#style/Theme.Sherlock.Light">
<item name = "actionBarWidgetTheme"> #style/Theme.Sherlock.Light.DarkActionBar </item>
<item name = "android:actionBarWidgetTheme"> #style/Theme.Sherlock.Light.DarkActionBar </item>
<item name = "actionBarStyle"> #style/CustomTheme.ActionBarStyle </item>
<item name = "android:actionBarWidgetTheme"> #style/CustomTheme.ActionBarStyle </item>
</style>
Thanks ASP for answer.

Related

Changing Color of Tab Text in ActionBarActivity

I have an app using the support ActionBarActivity (android.support.v7.app.ActionBarActivity), with tabs. I used the Action Bar Style Generator to change the look of the app, but now I am having a hard time getting the tab text color to change.
The style is being applied through the manifest, and shows up just fine except for the tab text color remains black no matter what I try. Here's what I have in my custom styles xml file right now:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.StyledActionBar" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_StyledActionBar</item>
<item name="popupMenuStyle">#style/PopupMenu.StyledActionBar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.StyledActionBar</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.StyledActionBar</item>
<item name="actionDropDownStyle">#style/DropDownNav.StyledActionBar</item>
<item name="actionBarStyle">#style/ActionBar.Solid.StyledActionBar</item>
<item name="actionModeBackground">#drawable/cab_background_top_StyledActionBar</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_StyledActionBar</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.StyledActionBar</item>
<item name="actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="android:actionBarTabTextStyle">#style/TabTextStyle</item>
</style>
<style name="TabTextStyle" parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.Solid.StyledActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_StyledActionBar</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_StyledActionBar</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_StyledActionBar</item>
<item name="progressBarStyle">#style/ProgressBar.StyledActionBar</item>
</style>
<style name="ActionBar.Transparent.StyledActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_StyledActionBar</item>
<item name="progressBarStyle">#style/ProgressBar.StyledActionBar</item>
</style>
<style name="PopupMenu.StyledActionBar" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_StyledActionBar</item>
</style>
<style name="DropDownListView.StyledActionBar" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_StyledActionBar</item>
</style>
<style name="ActionBarTabStyle.StyledActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_StyledActionBar</item>
</style>
<style name="DropDownNav.StyledActionBar" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_StyledActionBar</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_StyledActionBar</item>
<item name="android:dropDownSelector">#drawable/selectable_background_StyledActionBar</item>
</style>
<style name="ProgressBar.StyledActionBar" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_StyledActionBar</item>
</style>
<style name="ActionButton.CloseMode.StyledActionBar" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_StyledActionBar</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.StyledActionBar.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.StyledActionBar</item>
<item name="dropDownListViewStyle">#style/DropDownListView.StyledActionBar</item>
</style>
</resources>
As you can see, I tried to change the color to white, but to no effect. I also was trying to change the Action Bar title color, but gave up because I found a java workaround.
ActionBarActivity is deprecated.
And you are using Theme.AppCompat : ActionBarActivity is deprecated
Try to use AppCompatActivity in your java codes(Activity).

Styling the Overflow Menu

I want to change the color of the overflow icon, menu background color, and text color. The Text color is changing, and I added a new icon but it is bigger than the original and the original is still there. How do I fix the overflow button and change the background color? Thanks in advance.
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<item name="android:colorAccent">#color/accent</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="android:windowBackground">#color/window_background</item>
<item name="android:actionOverflowMenuStyle">#style/AppTheme.Overflow</item>
<item name="actionOverflowButtonStyle">#style/AppTheme.Overflow</item>
<item name="android:popupMenuStyle">#style/AppTheme.PopupMenu</item>
<item name="android:textAppearanceLargePopupMenu" >#style/AppTheme.TextAppearanceLargePopupMenu</item>
<item name="android:textAppearanceSmallPopupMenu" >#style/AppTheme.TextAppearanceSmallPopupMenu</item>
</style>
<style name="AppTheme.Overflow" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:background">#drawable/ic_overflow</item>
</style>
<style name="AppTheme.PopupMenu" parent="Widget.AppCompat.ListPopupWindow">
<item name="android:popupBackground">#color/window_background</item>
</style>
<style name="AppTheme.TextAppearanceLargePopupMenu" parent="TextAppearance.AppCompat.Widget.PopupMenu.Large">
<item name="android:textColor">#color/light_text</item>
</style>
<style name="AppTheme.TextAppearanceSmallPopupMenu" parent="TextAppearance.AppCompat.Widget.PopupMenu.Small">
<item name="android:textColor">#color/light_text</item>
</style>
</resources>

How to style DialogPreference with a custom theme?

In my application I was using Theme.Holo and Theme.Holo.Light without any issues. When Holo theme is used and I click on a DialogPreference/ListPreference, a popped dialog is also themed with Holo. Same for the Holo.Light. But when PreferencesActivity is styled with my custom theme, which is derived from Holo.Light, all dialogs are themed with Holo.Light. I think I am missing somthing in my theme. Could anyone help me? Thanks a lot!
Here is my theme code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="GreenTheme" parent="android:Theme.Holo.Light">
<item name="android:editTextBackground">#drawable/edit_text_holo_light</item>
<item name="android:autoCompleteTextViewStyle">#style/AutoCompleteTextViewGreenTheme</item>
<item name="android:listChoiceIndicatorMultiple">#drawable/btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">#drawable/btn_radio_holo_light</item>
<item name="android:buttonStyle">#style/ButtonGreenTheme</item>
<item name="android:imageButtonStyle">#style/ImageButtonGreenTheme</item>
<item name="android:dropDownSpinnerStyle">#style/SpinnerGreenTheme</item>
<item name="android:tabWidgetStyle">#style/TabWidgetGreenTheme</item>
<item name="android:progressBarStyleHorizontal">#style/ProgressBarGreenTheme</item>
<item name="android:seekBarStyle">#style/SeekBarGreenTheme</item>
<item name="android:buttonStyleToggle">#style/ToggleGreenTheme</item>
<item name="android:listChoiceBackgroundIndicator">#drawable/list_selector_holo_light</item>
<item name="android:activatedBackgroundIndicator">#drawable/activated_background_holo_light</item>
<item name="android:fastScrollThumbDrawable">#drawable/fastscroll_thumb_holo</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Greenactionbar</item>
<item name="android:buttonBarButtonStyle">#style/ButtonBarButtonStyleGreenTheme</item>
<item name="android:preferenceStyle">#style/TimePickerDialogFragmentGreen</item>
</style>
<style name="TimePickerDialogFragmentGreen" parent="#android:style/Theme.Holo.Light.Dialog">
<item name="android:editTextBackground">#drawable/edit_text_holo_light</item>
<item name="android:autoCompleteTextViewStyle">#style/AutoCompleteTextViewGreenTheme</item>
<item name="android:listChoiceIndicatorMultiple">#drawable/btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">#drawable/btn_radio_holo_light</item>
<item name="android:buttonStyle">#style/ButtonGreenTheme</item>
<item name="android:imageButtonStyle">#style/ImageButtonGreenTheme</item>
<item name="android:dropDownSpinnerStyle">#style/SpinnerGreenTheme</item>
<item name="android:tabWidgetStyle">#style/TabWidgetGreenTheme</item>
<item name="android:progressBarStyleHorizontal">#style/ProgressBarGreenTheme</item>
<item name="android:seekBarStyle">#style/SeekBarGreenTheme</item>
<item name="android:buttonStyleToggle">#style/ToggleGreenTheme</item>
<item name="android:listChoiceBackgroundIndicator">#drawable/list_selector_holo_light</item>
<item name="android:activatedBackgroundIndicator">#drawable/activated_background_holo_light</item>
<item name="android:fastScrollThumbDrawable">#drawable/fastscroll_thumb_holo</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Greenactionbar</item>
<item name="android:buttonBarButtonStyle">#style/ButtonBarButtonStyleGreenTheme</item>
</style>
</resources>
I found this rather unformatted but otherwise nice answer.
The gist is that DialogPreferences are AlertDialogs created without the theme parameter, which means they apply which ever theme android:alertDialogTheme points to.
So I extended my theme like this to have the dialog themed:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/yellow_500</item>
<item name="colorPrimaryDark">#color/yellow_a700</item>
<item name="colorAccent">#color/purple_400</item>
<item name="android:alertDialogTheme">#style/DialogTheme</item>
</style>
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">#color/yellow_500</item>
<item name="colorPrimaryDark">#color/yellow_a700</item>
<item name="colorAccent">#color/purple_400</item>
<item name="android:windowMinWidthMinor">#android:dimen/dialog_min_width_minor</item>
</style>
</resources>
The colorPrimary, colorPrimaryDark and colorAccent in the AppTheme were the colours I wanted to have applied to the dialog as well.
Note that I needed the android:windowMinWidthMinor to prevent the dialog from collapsing horizontally.
I have clarifying questions, but can't ask them because of low rate. So: 1.Does your first style work correctly? 2.Are you sure, that theme #android:style/Theme.Holo.Light.Dialog has all items, you declared in TimePickerDialogFragmentGreen?For example:
<item name="android:tabWidgetStyle"> #style/TabWidgetGreenTheme</item>
3. Have you tried the idea proposed by Luksprog
And finally: I used something like that to create custom style for my EditTexts:
<style name="EditTextStyle" parent="#style/Indents">
<item name="android:textColor">#android:color/black</item>
<item name="android:background">#android:color/white</item>
<item name="android:textColorHint">#android:color/darker_gray</item>
<item name="android:textSize">14sp</item>
</style>
<style name="Indents" parent="#style/Margins">
<item name="android:paddingBottom">#dimen/activity_vertical_padding</item>
<item name="android:paddingTop">#dimen/activity_vertical_padding</item>
</style>
<style name="Margins">
<item name="android:layout_marginTop">#dimen/activity_vertical_margin </item>
<item name="android:layout_marginBottom">#dimen/activity_vertical_margin </item>
<item name="android:layout_marginLeft">#dimen/activity_horizontal_margin </item>
<item name="android:layout_marginRight">#dimen/activity_horizontal_margin </item>
</style>

Actionbar Sherlock Change Title Color

I am trying the Theme Sherlock Action Bar. I want to set the color of the Title as White. When i try to do the following the Title disappears all together.
Also I want to change the background color of an Action Item Icon when Pressed.
What i have tried ?
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Variation on the Holo Light theme that styles the Action Bar -->
<style name="Theme.Nomad" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Widget.Nomad.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Nomad.ActionBar</item>
<item name="android:actionBarItemBackground">#drawable/actionbar_selectable_background</item>
<item name="actionBarItemBackground">#drawable/actionbar_selectable_background</item>
<item name="android:titleTextStyle">#style/TitleText</item>
<item name="titleTextStyle">#style/TitleText</item>
<!--
<item name="android:popupMenuStyle">#style/MyPopupMenu</item>
<item name="popupMenuStyle">#style/MyPopupMenu</item>
<item name="android:dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="android:actionBarTabStyle">#style/MyActionBarTabStyle</item>
<item name="actionBarTabStyle">#style/MyActionBarTabStyle</item>
<item name="android:actionDropDownStyle">#style/MyDropDownNav</item>
<item name="actionDropDownStyle">#style/MyDropDownNav</item>
<item name="android:listChoiceIndicatorMultiple">#drawable/ad_btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">#drawable/ad_btn_radio_holo_light</item>
<item name="android:actionOverflowButtonStyle">#style/MyOverflowButton</item>
-->
</style>
<style name="Widget.Nomad.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#E5492A</item>
<item name="background">#E5492A</item>
</style>
<style name="TitleText" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
<item name="textColor">#android:color/white</item>
<item name="android:textSize">18dip</item>
<item name="textSize">18dip</item>
</style>
</resources>
I am not sure about item background, but for text color you can:
add these items in Widget.Nomad.ActionBar (style with parent Widget.Sherlock.ActionBar):
<item name="android:titleTextStyle">#style/TitleText</item>
<item name="titleTextStyle">#style/TitleText</item>
where:
<style name="TitleText" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
<item name="android:textSize">18sp</item>
</style>
The best solution is this!
actionBar.setTitle(Html.fromHtml("<font color=\"#ffffff\"><b>" + AppName + "</b></font>"));
I promise it will be very helpful! Good luck!

Modify style of Android items in the ActionBar

How can I modify the style of the items on the Action bar of an Android Application?
I tryed the following:
<item name="android:actionBarStyle">#style/ActionBar.Light</item>
<style name="ActionBar.Light" parent="#style/ActionBar">
<item name="android:background">#color/black</item>
<item name="android:actionMenuTextColor">#FF00FF</item>
</style>
The background of the Action bar I was able to modify, but not the text Colors of the items in the Action bar. How can I do it?
EDIT:
I tried pretty much all the android:action attributes I found, but I couldn't manage to change anything other than the background. Only the first <item name="android:background">#FF0000</item> of the following code makes changes on my code. No matter which values I put on the Test style, it doesn't change anything. Why is it happening?
<item name="android:actionBarStyle">#style/ActionBar.Light</item>
<style name="ActionBar.Light" parent="#style/ActionBar">
<item name="android:background">#FF0000</item>
<item name="android:actionMenuTextColor">#style/Test</item>
<item name="android:actionButtonStyle">#style/Test</item>
<item name="android:actionModeBackground">#style/Test</item>
<item name="android:actionMenuTextAppearance">#style/Test</item>
</style>
<style name="Test">
<item name="android:textColor">#color/white</item>
<item name="android:background">#FF0000</item>
</style>
If you want to change the color of the menu items in the action bar you have to set the actionMenuTextColor in your theme style.
<style name="PortfolioTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionMenuTextColor">#24598a</item>
<item name="actionMenuTextColor">#24598a</item>
</style>
You don't define the menu item colors in the actionMenuTextAppearance!
You can change the color by:-
<?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.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>

Categories

Resources