Option Menu show incorrectly on Custom Style map - java

Option Menu show incorrectly on Custom Style map
The problem raised on an application in android
I have a custom theme on my app. The problem is that the option menu shows incorrectly ,so the option menu shows cut of on the screen.
I wondering why could happen?
This is my style file xml
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:typeface">normal</item>
<item name="android:typeface">sans</item>
<item name="android:typeface">serif</item>
<item name="android:typeface">monospace</item>
<item name="android:actionBarItemBackground">#drawable/selectable_background_example</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Example</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Example</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Example</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Example</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Example</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_example</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_example</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Example</item>
</style>
<style name="ActionBar.Solid.Example" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_solid_example</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_example</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="ActionBar.Transparent.Example" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_transparent_example</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="PopupMenu.Example" parent="#android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>
<style name="DropDownListView.Example" parent="#android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_example</item>
</style>
<style name="ActionBarTabStyle.Example" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_example</item>
</style>
<style name="DropDownNav.Example" parent="#android:style/Widget.Holo.Light.Spinner">
<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="#android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_example</item>
</style>
<style name="ActionButton.CloseMode.Example" parent="#android:style/Widget.Holo.Light.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="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.Example</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Example</item>
</style>

For any ones that have this same trouble, the solution , in my case , was solved by added this line in the manifest file.
<supports-screens
android:anyDensity="true" />

Related

The text of options of edittext selection mode are not completly visible

This is my EditText's selection mode style.
As you can see it's texts are not completely visible.
This is my styles.xml file:
<style name="MyApp" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primaryDark</item>
<item name="colorOnPrimary">#color/onPrimary</item>
<item name="colorSecondary">#color/secondary</item>
<item name="colorSecondaryVariant">#color/secondaryLight</item>
<item name="colorOnSecondary">#color/onSecondary</item>
<item name="colorError">#color/error</item>
<item name="colorOnError">#color/onError</item>
<item name="colorSurface">#color/surface</item>
<item name="android:textViewStyle">#style/DefaultTextStyle</item>
<item name="buttonStyle">#style/DefaultButtonStyle</item>
<item name="materialButtonStyle">#style/DefaultButtonStyle</item>
<item name="android:textColorPrimary">#color/enabledColor</item>
<item name="bottomSheetDialogTheme">#style/BottomSheetTheme</item>
<item name="textAppearanceBody1">#style/BodyAppearance</item>
<item name="textAppearanceSubtitle1">#style/Subtitle1Appearance</item>
<item name="textAppearanceSubtitle2">#style/Subtitle2Appearance</item>
<item name="textAppearanceButton">#style/ButtonAppearance</item>
<item name="textAppearanceHeadline1">#style/Headline1</item>
<item name="textAppearanceCaption">#style/Caption</item>
<item name="popupMenuStyle">#style/PopupMenuStyle</item>
<item name="transparentPrimaryColor">#color/transparentPrimary</item>
<item name="colorOnSurface">#color/onSurface</item>
<item name="windowActionModeOverlay">true</item>
<item name="windowNoTitle">true</item>
<item name="actionModeBackground">?attr/colorSecondary</item>
<item name="actionBarTheme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="android:popupWindowStyle">#style/PopupWindodwStyle</item>
</style>
I found out that deleting textAppearanceButton attribute somehow fixes the problem. This is how the value of textAppearanceButton look like:
<style name="ButtonAppearance" parent="MyApp">
<item name="fontFamily">#font/iransans_bold</item>
<item name="android:textSize">14sp</item>
</style>
I cannot delete that attribute because I've used it throughout my application. Does anyone know why this problem happens? Thanks.

How to change MaterialAlertDialog theme

Here is a dialog, how to change this color (unchecked)?
I try to set style but not work:
<style name="ThemeMyAppDialogAlertDay"
parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="colorPrimary">#color/color_secondary</item>
<item name="colorPrimaryVariant">#color/color_primary_variant</item>
<item name="colorOnPrimary">#color/color_secondary</item>
<item name="colorSecondary">#color/color_secondary</item>
<item name="colorAccent">#color/color_error</item>
</style>
You can use:
<style name="ThemeMyAppDialogAlertDay"
parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="colorSecondary">#color/selected</item> <!-- selected -->
<item name="colorControlNormal">#color/unselected</item> <!-- unselected -->
</style>
Try this , It should help
<style name="materialDiaog" parent="MaterialAlertDialog.MaterialComponents">
<item name="buttonTint">#color/colorPrimary</item>
<item name="colorPrimary">#color/color_secondary</item>
<item name="colorPrimaryVariant">#color/color_primary_variant</item>
<item name="colorOnPrimary">#color/color_secondary</item>
<item name="colorSecondary">#color/color_secondary</item>
<item name="colorAccent">#color/color_error</item>
</style>
<style name="AppTheme" parent="{set your parent theme here}">
<item name="materialAlertDialogTheme">#style/materialDiaog</item>
</style>

How to change Actionbar text color using Material Design?

I am using Material Design in my Android app and I want to change Actionbar text color and back button color.
This code is not working:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowContentOverlay">#null</item>
<!--<item name="android:textSize">3sp</item>-->
<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/titleColor</item>
</style>
Using the ActionBar in your theme you can use:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="actionBarTheme">#style/ThemeOverlay.Actionbar</item>
</style>
<style name="ThemeOverlay.Actionbar" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" >
<item name="android:textColorPrimary">#color/....</item>
</style>

Android: ActionBar will not change its style?

I'm following the Android Documentation and have correctly copied this code:
<resources>
<style name="CustomTheme"
parent="Base.Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionMenuTextColor">#color/actionbar_text</item>
</style>
<style name="MyActionBar"
parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#color/background</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
</style>
</resources>
I've set the activities manifest to "CustomTheme" and have the right information in strings.xml so I don't see what the problem would be. Any help would be appreciated. Thanks.
Try removing the android: tag and also, you have to set the Parent ActionBar to AppCompat's ActionBar.
<style name="CustomTheme"
parent="Base.Theme.AppCompat.Light">
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
</style>
<style name="MyActionBar"
parent="Base.Widget.AppCompat.ActionBar">
<item name="background">#color/background</item>
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
</style>

Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Base'. styles.xml /LaunchActivity/res/values

I have tried a lot of changes but I never seem to get rid of this error, I don't have any library imported because I lost all data.
<style name="TextAppearance.AppCompat.Light.Widget.PopupMenu.Large" parent="#style/TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Large" />
<style name="TextAppearance.AppCompat.Light.Widget.PopupMenu.Small" parent="#style/TextAppearance.AppCompat.Light.Base.Widget.PopupMenu.Small" />
<style name="TextAppearance.AppCompat.SearchResult.Title" parent="#style/TextAppearance.AppCompat.Base.SearchResult.Title" />
<style name="TextAppearance.AppCompat.SearchResult.Subtitle" parent="#style/TextAppearance.AppCompat.Base.SearchResult.Subtitle" />
<style name="TextAppearance.AppCompat.Light.SearchResult.Title" parent="#style/TextAppearance.AppCompat.Light.Base.SearchResult.Title" />
<style name="TextAppearance.AppCompat.Light.SearchResult.Subtitle" parent="#style/TextAppearance.AppCompat.Light.Base.SearchResult.Subtitle" />
<style name="Widget.AppCompat.AutoCompleteTextView" parent="#style/Widget.AppCompat.Base.AutoCompleteTextView" />
<style name="Widget.AppCompat.Light.AutoCompleteTextView" parent="#style/Widget.AppCompat.Light.Base.AutoCompleteTextView" />
<style name="Widget.AppCompat.ActivityChooserView" parent="#style/Widget.AppCompat.Base.ActivityChooserView" />
<style name="Widget.AppCompat.Light.ActivityChooserView" parent="#style/Widget.AppCompat.Light.Base.ActivityChooserView" />
<style name="Widget.AppCompat.Base.ActionBar">
<item name="actionOverflowButtonStyle">#style/Widget.AppCompat.ActionButton.Overflow</item>
<item name="actionButtonStyle">#style/Widget.AppCompat.ActionButton</item>
<item name="height">?actionBarSize</item>
<item name="displayOptions">useLogo|showHome|showTitle</item>
<item name="titleTextStyle">#style/TextAppearance.AppCompat.Widget.ActionBar.Title</item>
<item name="subtitleTextStyle">#style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle</item>
<item name="divider">?dividerVertical</item>
<item name="background">#drawable/abc_ab_transparent_dark_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_stacked_transparent_dark_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_transparent_dark_holo</item>
<item name="homeLayout">#layout/abc_action_bar_home</item>
<item name="progressBarStyle">#style/Widget.AppCompat.ProgressBar.Horizontal</item>
<item name="indeterminateProgressStyle">#style/Widget.AppCompat.ProgressBar</item>
</style>
<style name="Widget.AppCompat.Light.Base.ActionBar" parent="#style/Widget.AppCompat.Base.ActionBar">
<item name="actionOverflowButtonStyle">#style/Widget.AppCompat.Light.ActionButton.Overflow</item>
<item name="actionButtonStyle">#style/Widget.AppCompat.Light.ActionButton</item>
<item name="background">#drawable/abc_ab_transparent_light_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_stacked_transparent_light_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_transparent_light_holo</item>
<item name="progressBarStyle">#style/Widget.AppCompat.ProgressBar.Horizontal</item>
<item name="indeterminateProgressStyle">#style/Widget.AppCompat.ProgressBar</item>
</style>
<style name="Widget.AppCompat.Base.ActionBar.Solid" parent="#style/Widget.AppCompat.Base.ActionBar">
<item name="background">#drawable/abc_ab_solid_dark_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_stacked_solid_dark_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_solid_dark_holo</item>
</style>
<style name="Widget.AppCompat.Light.Base.ActionBar.Solid" parent="#style/Widget.AppCompat.Light.Base.ActionBar">
<item name="background">#drawable/abc_ab_solid_light_holo</item>
<item name="backgroundStacked">#drawable/abc_ab_stacked_solid_light_holo</item>
<item name="backgroundSplit">#drawable/abc_ab_bottom_solid_light_holo</item>
</style>
<style name="Widget.AppCompat.Light.Base.ActionBar.Solid.Inverse" parent="#style/Widget.AppCompat.Base.ActionBar.Solid">
<item name="actionOverflowButtonStyle">#style/Widget.AppCompat.ActionButton.Overflow</item>
<item name="actionButtonStyle">#style/Widget.AppCompat.ActionButton</item>
<item name="titleTextStyle">#style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse</item>
<item name="subtitleTextStyle">#style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse</item>
</style>
<style name="Widget.AppCompat.Base.ActionButton">
<item name="android:gravity">center</item>
<item name="android:background">?actionBarItemBackground</item>
<item name="android:paddingLeft">12.0dip</item>
<item name="android:paddingRight">12.0dip</item>
<item name="android:minWidth">#dimen/abc_action_button_min_width</item>
<item name="android:minHeight">?actionBarSize</item>
<item name="android:maxLines">2</item>
<item name="textAllCaps">#bool/abc_config_actionMenuItemAllCaps</item>
</style>
The errors occurs in these follow lines
<style name="Widget.AppCompat.Base.ActionBar">
And this
<style name="Theme.AppCompat.Base.CompactMenu">
Please help me out, I'm a newbie so step by step is highly appreciated!

Categories