TL;DR;
How to remove the below unwanted white area?
I tried to change my theme which extends "Theme.AppCompat.Light.NoActionBar" and added my own customization.
After using the theme, all "pop-up" buttons have an extra white background like above screenshot:
How to remove those extra white area?
What xml attributes are controlling this?
styles.xml
<style name="MyCustomTheme" 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="android:textColorSecondary">#color/secondary_text</item>
<item name="android:alertDialogTheme">#style/CustomAppCompatAlertDialogStyle</item>
<item name="android:actionBarStyle">#style/CustomActionBarStyle</item>
</style>
Related
In Android, is there any way to give an ActionMode the same appearance as the normal Toolbar? Currently my ActionMode looks different to the Toolbar in that the background is slightly brighter (at least using Theme.AppCompat.NoActionBar), the MenuItems are fully black/white (depending on the theme) instead of colorControlNormal (which I set them to) and most annoyingly, there is an underline under the ActionMode that I can't seem to get rid of. Instead, I'm trying to make the ActionMode indistinguishable from the Toolbar.
The Toolbar (also what the ActionMode is meant to look like):
What the ActionMode currently looks like:
Any help would be highly appreciated!
For changing the background color of ActionMode & Remove the bottom line. You can use actionModeStyle where you can set background to your desired color.
For changing the icon color you can set colorControlNormal inside the actionBarTheme.
So your theme would look like this:
<style name="Theme.AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<!--add this-->
<item name="actionModeStyle">#style/ActionModeStyle</item>
<item name="actionBarTheme">#style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
//replace with your own desired color
<item name="colorControlNormal">#a00</item>
</style>
<style name="ActionModeStyle" parent="#style/Widget.AppCompat.ActionMode">
//replace with your own desired color
<item name="background">#color/colorPrimary</item>
<item name="titleTextStyle">#style/ActionModeTitleTextStyle</item>
</style>
<style name="ActionModeTitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionMode.Title">
//replace with your own desired color
<item name="android:textColor">#a00</item>
</style>
Please tell me, I have an application that uses a webView in full screen. As of android 10, the navigation bar started to overlap my webView:
By putting <item name="android:windowTranslucentNavigation">true</item>, the navigation bar stopped overlapping the webView, but I would like to make it black and but not transparent. How can I implement this? Perhaps I can do something differently so that the navigation bar does not overlap the webView? I'm new to this.
My style.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/background_splashscreen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:navigationBarColor">#color/black</item>
</style>
Thanks in advance.
I have defined a relativeLayout with a recyclerView and an imageView. I want the imageView to draw behind the status bar. But for some reason
android:fitsSystemWindow = true
doesn't work.
How can I achieve it?
Set your full-screen theme like following
<style name="Theme.MyApp.FullScreen" parent="Theme.MyApp">
<item name="android:statusBarColor" tools:targetApi="lollipop">#android:color/transparent</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">true</item>
</style>
Don't add android:fitsSystemWindows="true" in your layout file
Also, no need to add android:windowSoftInputMode="adjustPan" in Manifest file
To draw behind status bar, You have to set your status bar have transparent background.
So, you need to set this with adding below proprieties in your theme:
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
And in your .xml you have already set below property which is useful:
android:fitsSystemWindows="true"
So in the app I am making, I have both a dark and light theme. The light theme works fine, but the alert dialogs I have still show the background the same as the light theme. Since it is dark, the text changes to light and the user can't see anything. Is there a certain attribute I need to change?
Here is the styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#E53935</item>
<item name="colorPrimaryDark">#C62828</item>
<item name="android:navigationBarColor">#E53935</item>
<item name="android:colorAccent">#1565C0</item>
<item name="android:colorForeground">#color/foreground_material_light</item>
<item name="android:colorBackground">#color/background_material_light</item>
<!-- Other attributes -->
</style>
<style name="Dark" parent="#style/AppTheme" >
<item name="android:colorForeground">#color/foreground_material_dark</item>
<item name="android:colorPrimary">#color/primary_material_dark</item>
<item name="android:colorPrimaryDark">#color/primary_dark_material_dark</item>
<item name="android:colorAccent">#color/accent_material_dark</item>
<item name="android:navigationBarColor">#color/primary_material_dark</item>
<item name="android:colorBackground">#color/background_material_dark</item>
<item name="android:textColorPrimary">#android:color/primary_text_dark</item>
<item name="android:textColorPrimaryInverse">#android:color/primary_text_light</item>
<item name="android:textColorSecondary">#android:color/secondary_text_dark</item>
<item name="android:textColorSecondaryInverse">#android:color/secondary_text_light</item>
<item name="android:textColorTertiary">#android:color/tertiary_text_dark</item>
</style>
Here is what it shows up as:
Solved: You need to create your own xml like this:
<item name="alertDialogTheme">#style/DarkAlertDialog</item>
With this being your custom dialog:
<style name="DarkAlertDialog" parent="Theme.AppCompat.Dialog">
<item name="background">#color/background_material_dark</item>
</style>
Use the parent AppCompat and then use colorPrimary and colorAccent properties (without an Android prefix) to theme things.
Right now the styles are coming from a dialog subtheme and not being affected by these style definitions.
I would really like to know if I am able to change the text color of the Appbar text in the PlacePicker API for Android. It should inherit the styling from my application, but it does not do that.
my styles.xml is as follows:
<style name="MaterialParent" parent="Theme.AppCompat.Light.NoActionBar">
<!-- ...and here we setting appcompat’s color theming attrs -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#color/secondary_text</item>
<item name="icon">#color/icons</item>
<item name="divider">#color/divider</item>
<item name="colorControlHighlight">#color/accent_alpha26</item>
</style>
<style name="Material" parent="MaterialParent"/>
I've already tried changing android:textColorPrimary, android:textColorSecondary and textColor to white with no luck.
Please use Theme.AppCompat.Light.NoActionBar instade of Theme.AppCompat.Light.DarkActionBar
Just change the colorPrimary value of color file with the color hex code, that you want and it works fine.