appcompat 23.2.1 menuitem text small case issue - android

I have added appcompat 23.2.1 support library.This library gives menu item text small for lollipop and above version devices but its shows in small case but its not shows in small case for older versions(It shows in capital ).I have used below code for it
=screnshot
<style name="Theme.app" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarTabTextStyle">#style/MyTabTextStyle</item>
<item name="android:textAllCaps">false</item>
<item name="android:actionBarTabTextStyle">#style/MyTabTextStyle</item>
<item name="actionMenuTextAppearance">#style/MyMenuTextAppearance</item>
<item name="android:actionMenuTextAppearance">#style/MyMenuTextAppearance</item>
<!-- Main theme colors -->
<item name="android:textColorPrimary">#color/white</item>
<item name="android:colorPrimary">#color/actionbartop</item>
<item name="android:colorPrimaryDark">#color/actionbartop</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyMenuTextAppearance" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="android:textAllCaps">false</item>
<item name="textAllCaps">false</item>
<item name="android:textSize">#dimen/default_textsize_menu</item>
</style>

you may use , android:capitalize="none" in layout

Related

Removing action bar's shadow

I would like to remove the action bar's shadow and although there are many similar questions, no of the suggestions works for me. I am using 4.3 Api 18 and would like to work for lower and upper versions. Here is my code:
<style name="MyActionBar" parent="style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="elevation">0dp</item>
<item name="android:actionBarStyle">#style/LineRemover</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
<style name="LineRemover" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#android:color/transparent</item>
</style>
<style name="Base.AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="actionOverflowMenuStyle">#style/OverflowMenu</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
Update:
I decide to use a Toolbar as suggested in the comments and now everything works fine.
try this , for 5.0
<item name="app:elevation">0dp</item>
or try
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>

How to change the height of the contextual action mode on lollipop and above device?

I have implemented the floatingsearchview from here. In my activity i am also having the action mode which is enable on long press on list item.On pre-lollipop the action mode overlays the whole searchview but on post lollipop devices it doesn't as seen in the pictures below
The problem is highlighted in below image.
So i want to increase the height of the action mode how can i do it.Well i already tried with styles attribute in style file.My activity current used style is shown below.
<style name="AppTheme.ContexualActionMode">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorButtonNormal">#color/primary</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionModeBackground">#color/actionModeBachgroundColor</item>
</style>
I also tried this but no solution.
<style name="Widget.ActionModeStyle" parent="#style/Widget.AppCompat.ActionMode">
<item name="android:background">#drawable/action_mode_background</item>
<item name="titleTextStyle">#style/TitleTextStyle</item>
<item name="android:height">70dp</item><!--or something-->
</style>
with activity style
<style name="AppTheme.ContexualActionMode">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorButtonNormal">#color/primary</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionModeStyle">#Widget.ActionModeStyle</item>
</style>
can any one help me please.
I guess you found your answer (hopefully) after this long but I was just struggeling with this issue and what worked for me is this:
<style name="AppTheme.ActionMode" parent="#style/Widget.AppCompat.ActionMode">
<item name="background">#color/Blue</item>
<item name="height">104dp</item>
<item name="titleTextStyle">#style/myTitleTextStyle</item>
</style>
and this in your appTheme style
<item name="actionModeStyle">#style/AppTheme.ActionMode</item>
it finally worked for me when i removed the android: prefix from the items

Possible problematic style of Toolbar

This case is related to the following problem.
In the case I believe it may be a problem with the style I'm trying to use the toolbar. I need you to stay in the Toolbar overlay, it has a drawer menu, and the lollipop operate normally, lower some versions.
style.xml v21
<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/accent</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<!-- enable window content transitions -->
<item name="android:windowContentTransitions">true</item>
</style>
style.xml
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowContentTransitions">true</item>
</style>
<style name="AppTheme" parent="AppTheme.Base">
</style>
If you are ok, someone could help me in this case the toolbar and the drawer disappear?
I found the solution to my problem. It was a possible conflict in style but rather a problem of organizing the objects on the screen.
With this following code could play the elements that disappeared in front of the camera.
getActivity().findViewById(R.id.DrawerLayout).bringToFront();
getActivity().findViewById(R.id.DrawerLayout).invalidate();
getActivity().findViewById(R.id.DrawerLayout).requestLayout();
In this case I have to get the reference of DrawerLayout and not the Toolbar. Thus the issue is resolved.

Action bar popup background is not changing

#style/Theme.MyAppTheme.ActionBar
<item name="android:popupMenuStyle">#style/popupMenuStyle</item>
<item name="android:actionBarWidgetTheme">#style/Theme.MyTheme.Widget</item>
<item name="android:actionBarItemBackground">#null</item>
<item name="android:listPreferredItemHeightSmall">45dp</item>
<style name="popupMenuStyle" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#android:color/white</item>
</style>
<style name="Theme.MyTheme.Widget" parent="#android:style/Theme.Holo">
<item name="android:textColor">#0675bc</item>
<item name="android:background">#android:color/white</item>
</style>
I have an activity which is having action bar overflow menu and my custom pop up menu I am using Theme.MyTheme.Widget in the above code it is working fine but the problem is I am using search view in action bar in another activity.Now the problem is if I am using the above code to change the overflow menu background this changes are applying to the search bar also which I don't need
if you API is minimum API level 14 , you can change with this (worked for me).
<style name="Theme.myapp" parent="#style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">#style/myapp_DropDownNav</item>
<item name="android:actionBarWidgetTheme">#style/myapp.actionBarWidgetTheme</item>
</style>
<style name="myapp.actionBarWidgetTheme" parent="#style/Theme.">
<item name="android:spinnerDropDownItemStyle">#style/myapp.Widget.DropDownItem.Spinner</item>
</style>
<style name="myapp_DropDownNav" parent="#style/Widget.Spinner.DropDown.ActionBar">
<item name="background">#drawable/spinner_background_ab_myapp</item>
<item name="android:background">#drawable/spinner_background_ab_myapp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_myapp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_myapp</item>
</style>
<style name="myapp.Widget.DropDownItem.Spinner" parent="Widget.DropDownItem.Spinner">
<item name="android:textAppearance">#style/myapp.TextAppearance.Widget.DropDownItem</item>
</style>
<style name="myapp.TextAppearance.Widget.DropDownItem" parent="TextAppearance.Widget.DropDownItem">
<item name="android:textColor">#color/black</item>
</style>
if you are using ActionBarSherlock (minimun API level 9), try this:
<style name="Theme.yourapp" parent="#style/Theme.Sherlock.Light">
<item name="popupMenuStyle">#style/PopupMenu.Style</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Style</item> </style>
<style name="PopupMenu.Style" parent="#style/Widget.Sherlock.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/your_background</item>
</style>
<style name="DropDownListView.Style" parent="#style/Widget.Sherlock.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/your_background</item>
</style>
Hope it helps you!!

Android: styling overflow menu in action bar

I am using v7 support library in my project. My manifest settings are:
android:minSdkVersion="7"
android:targetSdkVersion="15"
I used Android Action Bar Style Generator to generate styles for my Action Bar. The problem is that while everything works for the newest apis, my overflow menu does not change in low apis (tested on emulator 2.2 and real device 2.3.3 htc desire).
(this should have red background)
Is menu overflow loading items in some other component like spinner dialog or something (sry if that sounds dumb) ? Why styles for one api(ex 15) doesn't apply for other(ex 8), and is there anything i can do to have same overflow menu for all api versions.
This is my original generated style from Action Bar Style Generator which i tweaked a lot but with no success.
<resources>
<style name="Theme.Example" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_example</item>
<item name="popupMenuStyle">#style/PopupMenu.Example</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Example</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Example</item>
<item name="actionDropDownStyle">#style/DropDownNav.Example</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Example</item>
<item name="actionModeBackground">#drawable/cab_background_top_example</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_example</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Example</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Example.Widget</item>
</style>
<style name="ActionBar.Solid.Example" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_example</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_example</item>
<item name="progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="ActionBar.Transparent.Example" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_example</item>
<item name="progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="PopupMenu.Example" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>
<style name="DropDownListView.Example" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_example</item>
</style>
<style name="ActionBarTabStyle.Example" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_example</item>
</style>
<style name="DropDownNav.Example" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_example</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
<item name="android:dropDownSelector">#drawable/selectable_background_example</item>
</style>
<style name="ProgressBar.Example" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_example</item>
</style>
<style name="ActionButton.CloseMode.Example" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_example</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Example.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Example</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Example</item>
</style>
I did it this way:
<style name="Theme.yourapp" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarWidgetTheme">#style/Theme.yourapp.Widget</item>
</style>
<style name="Theme.yourapp.Widget" parent="#style/Theme.AppCompat">
<item name="android:textColor">#android:color/black</item>
</style>
For simplicity, the android: namespace pertains to anything built into the OS while anything without android: as the namespace would pertain to your application (and the libraries you are using). Most, if not all, support libraries for the ActionBar will try to use the native ActionBar implementation and therefor use the android: namespace attributes in your styles. When the native ActionBar is not available it would use the libraries implementation and the non-android: namespaced attributes. This is why you must specify every attribute with and without the android: namespace.

Categories

Resources