I have attached the screenshot showing what I want to achieve. I want to achieve just one background for my popup menu. Now as you can see on the picture below my menu there is a second background? I want toi stay this one below (darker one) with rounded corners. How to fix this?
I am adding my style.xml
<style name="objectsmeasure_dark" parent="Theme.MaterialComponents.NoActionBar">
<item name="colorPrimary">#color/a212121</item>
<item name="colorPrimaryDark">#android:color/black</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:alertDialogTheme">#style/alert_dialog_dark</item>
<item name="android:windowBackground">#color/colorWindowBackgroundNight</item>
<item name="colorBg">#color/colorWindowBackgroundNight</item>
<item name="colorBottomNavigationViewBg">#color/bottom_nav_view_bg_night</item>
<item name="colorBottomNavigationViewItem">#color/bottom_nav_view_item_night</item>
<item name="android:popupMenuStyle">#style/popup_menu_dark</item>
<item name="popupMenuStyle">#style/popup_menu_dark</item>
<item name="myBackgroundColor">#color/colorGrey</item>
<item name="myEtBackgroundColor">#color/BF606060</item>
<item name="myCardBackground">#color/a212121</item>
<item name="myTextColor">#android:color/white</item>
<item name="myTintColor">#android:color/white</item>
<item name="myButtonColor">#color/colorButton</item>
<item name="myHintTextColor">#color/B3FFFFFF</item>
<item name="android:navigationBarColor">#android:color/black</item>
<item name="dialogTheme">#style/dialog_dark</item>
<item name="android:dialogTheme">#style/dialog_dark</item>
<item name="android:windowContentTransitions">true</item>
<item name="currentTheme">#style/objectsmeasure_dark</item>
</style>
<style name="popup_menu_dark" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#color/dark</item>
</style>
<style name="alert_dialog_dark" parent="Theme.MaterialComponents.Dialog.Alert">
<item name="colorPrimary">#color/colorButton</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:background">#color/dark</item>
<item name="background">#color/dark</item>
<item name="buttonBarPositiveButtonStyle">#style/alert_dialog_button_positive</item>
<item name="buttonBarNegativeButtonStyle">#style/alert_dialog_button_negative</item>
</style>
<style name="dialog_dark" parent="Theme.MaterialComponents.Dialog">
<item name="colorPrimary">#color/colorButton</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:background">#color/dark</item>
<item name="background">#color/dark</item>
<item name="buttonBarPositiveButtonStyle">#style/alert_dialog_button_positive</item>
<item name="buttonBarNegativeButtonStyle">#style/alert_dialog_button_negative</item>
</style>
Thank you for any help.
I solved this issue. It turned out I mixed parent styles - MaterialComponents and AppCompat and once I standarize it the problem was gone.
Related
Description: Numbers are not aligned on the center
Expected behavior: Numbers should be aligned on the center
Source code:
NOTE: The same behavior occured even before adding any style
<style name="OeamtcThemeOverlay_MaterialCalendar"
parent="#style/Theme.MaterialComponents.Light.Dialog">
<item name="android:colorAccent">#color/oeamtc_accent</item>
<item name="headerLayout">#style/Oeamtc_MaterialCalendar_Header</item>
<item name="android:colorButtonNormal">#color/oeamtc_accent</item>
<item name="android:button">#color/oeamtc_accent</item>
<item name="buttonBarPositiveButtonStyle">#style/ThemeMaterialCalendarButton</item>
<item name="buttonBarNegativeButtonStyle">#style/ThemeMaterialCalendarButton</item>
<item name="materialCalendarStyle">#style/Oeamtc_MaterialCalendar</item>
<item name="materialButtonStyle">#style/ThemeMaterialButton</item>
</style>
<style name="Oeamtc_MaterialCalendar"
parent="#style/Widget.MaterialComponents.MaterialCalendar">
<item name="rangeFillColor">#color/oeamtc_accent_transparent_50</item>
<item name="dayStyle">#style/Oeamtc_CalendarDay</item>
<item name="dayTodayStyle">#style/Oeamtc_CalendarToday</item>
<item name="daySelectedStyle">#style/Oeamtc_CalendarSelected</item>
</style>
<style name="ThemeMaterialCalendarButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">#color/oeamtc_accent</item>
</style>
<style name="ThemeMaterialButton" parent="Widget.MaterialComponents.Button">
<item name="android:textColor">#color/white</item>
<item name="android:backgroundTint">#color/oeamtc_accent</item>
</style>
<style name="Oeamtc_CalendarDay" parent="Test.Widget.MaterialComponents.MaterialCalendar.Day">
<item name="itemTextColor">#color/black</item>
<item name="itemFillColor">#color/transparent</item>
<item name="itemStrokeColor">#color/white</item>
<item name="itemStrokeWidth">0dp</item>
<item name="android:gravity">center</item>
<item name="itemShapeAppearance">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
<item name="itemShapeAppearanceOverlay">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
</style>
<style name="Oeamtc_CalendarSelected" parent="">
<item name="itemFillColor">#color/oeamtc_accent</item>
<item name="itemTextColor">#color/white</item>
<item name="itemStrokeColor">#color/oeamtc_accent</item>
<item name="itemStrokeWidth">0dp</item>
<item name="itemShapeAppearance">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
<item name="itemShapeAppearanceOverlay">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
</style>
<style name="Oeamtc_CalendarToday" parent="">
<item name="itemTextColor">#color/black</item>
<item name="itemStrokeColor">#color/oeamtc_accent</item>
<item name="itemFillColor">#color/white</item>
<item name="itemStrokeWidth">3dp</item>
<item name="itemShapeAppearance">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
<item name="itemShapeAppearanceOverlay">#style/Test.ShapeAppearanceOverlay.MaterialComponents.MaterialCalendar.Day</item>
</style>`
Android API version: 29
Material Library version: 1.1.0
Device: Oneplus 6t and all nexus emulators
I found the reason this happened. Apparently the main theme of the app has to inherit Material theme.
I want to define a new theme in my app, and override the default Holo AlertDialog style. But there's no way I can change the background or layout of my dialogs.
I followed partly the advice of this blog post.
These are the themes:
<style name="CD1.Theme" parent="android:style/Theme.Holo">
<!-- AlertDialog attributes -->
<item name="android:alertDialogTheme">#style/CD1.Theme.Dialog.Alert</item>
<item name="android:alertDialogStyle">#style/CD1.AlertDialog</item>
<item name="android:alertDialogCenterButtons">false</item>
<item name="android:alertDialogIcon">#drawable/cd1_ic_dialog_alert_holo</item>
</style>
<style name="CD1.Theme.Dialog.Alert" parent="android:style/Theme.Holo.Dialog.Alert">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowTitleStyle">#style/CD1.DialogWindowTitle</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowMinWidthMajor">#android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">#android:dimen/dialog_min_width_minor</item>
</style>
These are the styles:
<style name="CD1.AlertDialog" parent="android:style/AlertDialog.Holo">
<item name="android:fullDark">#drawable/cd1_dialog_full_holo</item>
<item name="android:topDark">#drawable/cd1_dialog_top_holo</item>
<item name="android:centerDark">#drawable/cd1_dialog_middle_holo</item>
<item name="android:bottomDark">#drawable/cd1_dialog_bottom_holo</item>
<item name="android:fullBright">#drawable/cd1_dialog_full_holo</item>
<item name="android:topBright">#drawable/cd1_dialog_top_holo</item>
<item name="android:centerBright">#drawable/cd1_dialog_middle_holo</item>
<item name="android:bottomBright">#drawable/cd1_dialog_bottom_holo</item>
<item name="android:bottomMedium">#drawable/cd1_dialog_bottom_holo</item>
<item name="android:centerMedium">#drawable/cd1_dialog_middle_holo</item>
<item name="android:layout">#layout/cd1_alert_dialog</item>
</style>
<style name="CD1.DialogWindowTitle" parent="android:style/DialogWindowTitle.Holo">
<item name="android:maxLines">1</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:textAppearance">#android:style/TextAppearance.Holo.DialogWindowTitle</item>
<item name="android:gravity">center</item>
</style>
It doesn't work. The default Holo layout is still displayed. What should I do?
Thanks.
Move <item name="android:alertDialogStyle">#style/CD1.AlertDialog</item> from CD1.Theme to CD1.Theme.Dialog.Alert:
<style name="CD1.Theme" parent="android:style/Theme.Holo">
<!-- AlertDialog attributes -->
<item name="android:alertDialogTheme">#style/CD1.Theme.Dialog.Alert</item>
<item name="android:alertDialogCenterButtons">false</item>
<item name="android:alertDialogIcon">#drawable/cd1_ic_dialog_alert_holo</item>
</style>
<style name="CD1.Theme.Dialog.Alert" parent="android:style/Theme.Holo.Dialog.Alert">
<item name="android:alertDialogStyle">#style/CD1.AlertDialog</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowTitleStyle">#style/CD1.DialogWindowTitle</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowMinWidthMajor">#android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">#android:dimen/dialog_min_width_minor</item>
</style>
By the way:
android:layout attribute requires API 11.
If you are developing against SDK which is below 11 your can consider this project:
https://github.com/fengdai/AlertDialogPro
I have created a custom progress dialog drawables.
<style name="MyTheme" parent="#android:style/Theme.Dialog">
<item name="android:alertDialogStyle">#style/CustomAlertDialogStyle</item>
<item name="android:textColorPrimary">#ABCDEF</item>
<item name="android:textColor"> #color/heading</item>
<item name="android:background">#00000000</item>
<item name="android:windowFrame">#null</item>
</style>
<style name="CustomAlertDialogStyle">
<item name="android:background">#00000000</item>
<item name="android:windowFrame">#null</item>
<item name="android:bottomBright">#color/grey</item>
<item name="android:bottomDark">#color/grey</item>
<item name="android:bottomMedium">#color/grey</item>
<item name="android:centerBright">#color/grey</item>
<item name="android:centerDark">#color/grey</item>
<item name="android:centerMedium">#color/grey</item>
<item name="android:fullBright">#color/grey</item>
<item name="android:fullDark">#color/grey</item>
<item name="android:topBright">#color/grey</item>
<item name="android:topDark">#color/grey</item>
</style>
Everything is working fine, its showing the things as it should. But dialog is showing borders. I want to remove those borders [screen shot attached].
use dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
You need to add the following to your CustomAlertDialogStyle too:
<item name="android:windowBackground">#android:color/transparent</item>
This question already has answers here:
How to change the text color of action bar sherlock
(3 answers)
Closed 9 years ago.
I have tried multiple different ways to change the tab text color to actionbarshelock to white and it simply does not work. Here is my styles.xml file.
<style name="Theme.Test" parent="#style/Theme.Sherlock.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_test</item>
<item name="popupMenuStyle">#style/PopupMenu.Test</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Test</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Test</item>
<item name="actionDropDownStyle">#style/DropDownNav.Test</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Test</item>
<item name="actionModeBackground">#drawable/cab_background_top_test</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_test</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Test</item>
<item name="android:actionBarItemBackground">#drawable/selectable_background_test</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Test</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Test</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Test</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Test</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Test</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_test</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_test</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Test</item>
</style>
<style name="ActionBar.Solid.Test" parent="#style/Widget.Sherlock.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_test</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_test</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_test</item>
<item name="progressBarStyle">#style/ProgressBar.Test</item>
<item name="android:background">#drawable/ab_solid_test</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_test</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_test</item>
<item name="android:progressBarStyle">#style/ProgressBar.Test</item>
<item name="android:titleTextStyle">#style/Test.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">#style/Test.ActionBar.TitleTextStyle</item>
<item name="actionBarTabTextStyle">#style/MyTabTextStyle</item>
<item name="android:actionBarTabTextStyle">#style/MyTabTextStyle</item>
<item name="android:actionBarStyle">#style/YOURTHEME.ActionBarStyle</item>
<item name="actionBarStyle">#style/YOURTHEME.ActionBarStyle</item>
</style>
<style name="YOURTHEME.ActionBarStyle" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:titleTextStyle">#style/YOURTHEME.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">#style/YOURTHEME.ActionBar.TitleTextStyle</item>
</style>
<style name="YOURTHEME.ActionBar.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
<style name="MyTabTextStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabText">
<item name="android:textColor">#color/white</item>
<item name="android:background">#color/white</item>
</style>
<style name="Test.ActionBar.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
<style name="ActionBar.Transparent.Test" parent="#style/Widget.Sherlock.Light.ActionBar">
<item name="background">#drawable/ab_transparent_test</item>
<item name="progressBarStyle">#style/ProgressBar.Test</item>
<item name="android:background">#drawable/ab_transparent_test</item>
<item name="android:progressBarStyle">#style/ProgressBar.Test</item>
</style>
<style name="PopupMenu.Test" parent="#style/Widget.Sherlock.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_test</item>
</style>
<style name="DropDownListView.Test" parent="#style/Widget.Sherlock.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_test</item>
</style>
<style name="ActionBarTabStyle.Test" parent="#style/Widget.Sherlock.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_test</item>
</style>
<style name="DropDownNav.Test" parent="#style/Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_test</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_test</item>
<item name="android:dropDownSelector">#drawable/selectable_background_test</item>
</style>
<style name="ProgressBar.Test" parent="#style/Widget.Sherlock.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_test</item>
</style>
<style name="ActionButton.CloseMode.Test" parent="#style/Widget.Sherlock.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_test</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Test.Widget" parent="#style/Theme.Sherlock">
<item name="popupMenuStyle">#style/PopupMenu.Test</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Test</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Test</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Test</item>
</style>
I want to make my text color white but I have no idea how to accomplish this. I'd appreciate if anyone can help me with this.
Thanks!
I got it to work.
This should be in the theme
<item name="actionBarTabTextStyle">#style/tabtextcolor</item>
<item name="android:actionBarTabTextStyle">#style/tabtextcolor</item>
This should be where you define the tab text color.
<style name="tabtextcolor" parent="#style/Widget.Sherlock.ActionBar.TabText">
<item name="android:textColor">#android:color/white</item>
</style>
is it possible to format a textview for a widget so that it looks like the text below the apps.
like in this screenshot:
i am looking for the exact textcolor, the exact dropshadow and the rounded background.
When in doubt, check with the source, which shows that Android is using a custom TextView to implement the bubbled background around the text.
It appears that the text itself is styled using styles in the launcher app:
<style name="WorkspaceIcon">
<item name="android:textSize">13dip</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">marquee</item>
<item name="android:shadowColor">#FF000000</item>
<item name="android:shadowRadius">2.0</item>
<item name="android:textColor">#FFF</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:background">#drawable/shortcut_selector</item>
<item name="android:paddingLeft">5dip</item>
<item name="android:paddingRight">5dip</item>
</style>
<style name="WorkspaceIcon.Portrait">
<item name="android:drawablePadding">5dip</item>
<item name="android:paddingTop">4dip</item>
<item name="android:layout_marginLeft">3dip</item>
<item name="android:layout_marginRight">3dip</item>
<item name="android:layout_marginTop">13dip</item>
<item name="android:layout_marginBottom">8dip</item>
</style>
<style name="WorkspaceIcon.Landscape">
<item name="android:drawablePadding">3dip</item>
<item name="android:paddingTop">2dip</item>
<item name="android:layout_marginLeft">10dip</item>
<item name="android:layout_marginRight">10dip</item>
</style>
Those styles are called from the launcher's layouts as appropriate.