Styling OptionMenu on android - android

Here is the default Option Menu style in android. Currently I tried.
My question is : I want to override the default to style of Option Menu. Like this!
which is only first character is cap and custom typeface.
Here is my implememtation.
//style.xml
<style name="HomeTheme" parent="AppTheme.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:fontFamily">#font/apercu</item>
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:actionMenuTextAppearance">#style/TextAppearance.Menu</item>
</style>
<style name="TextAppearance.Menu" parent="TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="android:fontFamily">#font/custom_type_face</item>
<item name="android:textSize">17sp</item>
<item name="android:textColor">#4d4d4d</item>
<item name="android:textAllCaps">false</item>
</style>

I accomplished it overriding AppTheme.Widget.ActionButton. Eg.
<style name="AppTheme.Widget.ActionButton" parent="#style/Widget.AppCompat.ActionButton">
<item name="textAllCaps">false</item>
</style>
and set it to my Activity's theme like
<item name="actionButtonStyle">#style/AppTheme.Widget.ActionButton</item>

Related

How to change the dialog's button colors for a Material Date picker

I'm using Material components to create a DatePicker. From what I understand, colorPrimary is used to determine the color of the section at the top of the dialog, as well as the colors for the text on the buttons, specifically CANCEL and OK.
Going through the documentation, I can't seem to find a way to change just the color of the buttons at the bottom ? Is it possible to do that ?
current code:
<style name="ThemeOverlay.App.DatePicker" parent="#style/ThemeOverlay.MaterialComponents.MaterialCalendar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorOnPrimary">#android:color/white</item>
<item name="shapeAppearanceSmallComponent">#style/ShapeAppearance.App.SmallComponent</item>
<item name="shapeAppearanceMediumComponent">#style/ShapeAppearance.App.MediumComponent
</item>
<item name="materialCalendarHeaderTitle">#style/MyHeaderTitle</item>
<item name="colorOnPrimarySurface">#android:color/white</item>
</style>
<style name="MyHeaderTitle" parent="Widget.MaterialComponents.MaterialCalendar.HeaderTitle">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ThemeMaterialCalendarTextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog.Flush">
<item name="android:textColor">#android:color/white</item>
<item name="iconTint">#android:color/white</item>
</style>
<style name="ShapeAppearance.App.SmallComponent" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="android:textSize">24sp</item>
<item name="cornerSize">16dp</item>
</style>
<style name="ShapeAppearance.App.MediumComponent" parent="ShapeAppearance.MaterialComponents.MediumComponent">
<item name="android:textSize">30sp</item>
<item name="cornerSize">16dp</item>
</style>
You can use:
builder.setTheme(R.style.MaterialCalendarTheme)
and then define:
<style name="MaterialCalendarTheme" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
<!-- Buttons -->
<item name="buttonBarPositiveButtonStyle">#style/TextButton</item>
<item name="buttonBarNegativeButtonStyle">#style/TextButton</item>
</style>
<style name="TextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">#color/...</item>
<item name="backgroundTint">#color/...</item>
</style>

Android TextColor

Does anyone know the way in which i am meant to code the change i want to make to the color of the ActionBar? I have tried using android:textColor , and android:color , as well as various other things. It seems like a quite a hassle for me. Although there is most probably a simple solution for this. Does anyone have any ideas?
Note: i am trying to make the font color white - from what i can tell, Android does this from the "actionbar.solid.pp" style.
<style name="Theme.Pp" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">#drawable/selectable_background_pp</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Pp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Pp</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Pp</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Pp</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Pp</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_pp</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_pp</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Pp</item>
</style>
<style name="ActionBar.Solid.Pp" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#111</item>
<item name="android:color">#FFF</item>
<item name="android:textStyle">bold</item>
<item name="android:progressBarStyle">#style/ProgressBar.Pp</item>
</style>
<style name="ActionBar.Transparent.Pp" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_transparent_pp</item>
<item name="android:progressBarStyle">#style/ProgressBar.Pp</item>
</style>
<style name="PopupMenu.Pp" parent="#android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_pp</item>
</style>
<style name="DropDownListView.Pp" parent="#android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_pp</item>
</style>
<style name="ActionBarTabStyle.Pp" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#ffffff</item>
</style>
<style name="DropDownNav.Pp" parent="#android:style/Widget.Holo.Light.Spinner">
<item name="android:background">#drawable/spinner_background_ab_pp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_pp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_pp</item>
</style>
<style name="ProgressBar.Pp" parent="#android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_pp</item>
</style>
<style name="ActionButton.CloseMode.Pp" parent="#android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_pp</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Pp.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.Pp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Pp</item>
</style>
Changing the action bar's text color is shown on the developer guide Styling the Action Bar
I think you can use this free tool to customize the style:
http://jgilfelt.github.io/android-actionbarstylegenerator/#name=example&compat=holo&theme=light&actionbarstyle=solid&texture=0&hairline=0&neutralPressed=1&backColor=E4E4E4%2C100&secondaryColor=D6D6D6%2C100&tabColor=33B5E5%2C100&tertiaryColor=F2F2F2%2C100&accentColor=33B5E5%2C100&cabBackColor=FFFFFF%2C100&cabHighlightColor=33B5E5%2C100

styling drop down/navigation bar actionbarsherlock font

In the application I have, I would like to have the actionbar drop down's font to be white. Till now I have the following style:
<style name="Theme.MyApplications" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/ActionBar.Solid</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ActionBar.Title" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.SubTitle" parent="TextAppearance.Sherlock.Widget.ActionBar.Subtitle">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.Solid" parent="#style/Widget.Sherlock.Light.ActionBar.Solid">
<item name="titleTextStyle">#style/ActionBar.Title</item>
<item name="subtitleTextStyle">#style/ActionBar.SubTitle</item>
</style>
This style gives me a black colored font in android 3.0 and higher. Can someone please help me configure the font to be white ?
The funny thing about this is that the action overflow popup's font appears in white.
for now I just used the simple
<style name="Theme.MyApplications" parent="#style/Theme.Sherlock">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#FFFFFF</item>
</style>
Its simple but it got the job done. And what got the job done was the change in the style's parent.
You have apply the style to the native ActionBar as well:
<style name="Theme.MyApplications" parent="#style/Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/ActionBar.Solid</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ActionBar.Title" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.SubTitle" parent="TextAppearance.Sherlock.Widget.ActionBar.Subtitle">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.Solid" parent="#style/Widget.Sherlock.Light.ActionBar.Solid">
<item name="titleTextStyle">#style/ActionBar.Title</item>
<item name="subtitleTextStyle">#style/ActionBar.SubTitle</item>
<item name="android:titleTextStyle">#style/ActionBar.Title</item>
<item name="android:subtitleTextStyle">#style/ActionBar.SubTitle</item>
</style>

Custom Spinner with white text color

I want my Action Bar spinner to display it's text in white (like in google maps app),
but i'm struggling to get there..
i'm trying something like this:
<style name="Mepo.Spinner" parent="#android:style/Widget.Spinner">
<item name="android:spinnerItemStyle">#style/StandardSpinnerItem</item>
<item name="spinnerItemStyle">#style/StandardSpinnerItem</item>
</style>
<style name="StandardSpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:textAppearance">#android:color/white</item>
<item name="android:textColor">#android:color/white</item>
</style>
but that has no effect.
I know this his probably been asked but i can't find the right solution.
any ideas?
p.s i'm actually using sherlock action bar if that matters
in the end this is what i did, maybe this will help someone:
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionDropDownStyle">#style/xxx.ActionBar.DropDown.Style</item>
<item name="android:actionDropDownStyle">#style/xxx.ActionBar.DropDown.Style</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">#0B2F39</item>
<item name="android:background">#0B2F39</item>
<item name="backgroundSplit">#0B2F39</item>
<item name="android:backgroundSplit">#0B2F39</item>
</style>
<style name="xxx.ActionBar.DropDown.Style" parent="Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/abs__spinner_ab_holo_dark</item>
</style>
if you have any remark or corretions i would love to hear them
If you already use an custom theme(you extended the base theme and customized it) and you want to customize the spinner only for one activity you need to do this:
<style name="Theme.MyTheme" parent="Theme.Sherlock">
... your other items
</style>
<style name="Theme.MyTheme.Spinner" parent="Theme.MyTheme">
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerItem.DropDownItem</item>
</style>
<style name="Spinner" parent="#android:style/Widget.Spinner">
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerItem.DropDownItem</item>
</style>
<style name="SpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="SpinnerItem.DropDownItem" parent="#android:style/Widget.Holo.Light.DropDownItem.Spinner">
<item name="android:textColor">#android:color/white</item>
</style>
And to use this style in an activity use this:
<activity
android:name=".YourActivity"
android:theme="#style/Theme.MyTheme.Spinner" >
</activity>
If you want to customize the spinner for all the activities(your application) move the items from Theme.MyTheme.Spinner into Theme.MyTheme:
<style name="Theme.MyTheme" parent="Theme.Sherlock">
... your other items
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerItem.DropDownItem</item>
</style>

ActionBarSherlock - How to set the padding of each actionbar's icon?

How can I make the icons of the actionbar using ActionBarSherlock closer or further away from each other? Something like android:layout_marginLeftor android:paddingRight?
If I just add the icons on the actionbar they are further away compare to the screenshot of Soundhound below:
my themes.xml:
<style name="Theme.AstraTheme_Purple" parent="#style/Theme.Sherlock">
<item name="actionBarStyle">#style/Widget.AstraTheme_Purple.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.AstraTheme_Purple.ActionBar</item>
<item name="actionButtonStyle">#style/Widget.AstraTheme_Purple.ActionButton</item>
<item name="android:actionButtonStyle">#style/Widget.AstraTheme_Purple.ActionButton</item>
</style>
<style name="Widget.AstraTheme_Purple.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#drawable/purple_bar</item>
<item name="background">#drawable/purple_bar</item>
</style>
<style name="Widget.AstraTheme_Purple.ActionButton" parent="Widget.Sherlock.ActionButton">
<item name="android:minWidth">50dip</item>
</style>
<style name="AppTheme" parent="Theme.Sherlock">
<item name="actionButtonStyle">#style/MyActionButtonStyle</item>
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="Widget.Sherlock.ActionButton">
<item name="android:minWidth">32dip</item>
<item name="android:padding">0dip</item>
</style>
The default value of android:minWidth for the ActionBar buttons is 56dip.
Don't forget to set #style/AppTheme as the Activity's theme.

Categories

Resources