Remove window background from appcompat v21 - android

I have a lot of overdraw in my app, which caused me to disable the window background completely. After upgrading to appcompat v21 the decorview has a solid color background again (its primaryColor). I tried the following to disable it:
<style name="AppBaseTheme" parent="Theme.Guidantswhite">
<item name="android:windowBackground">#null</item>
</style>
or in my base theme:
<style name="Theme.Guidantswhite" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<!-- Main theme colors -->
<!-- your app's branding color (for the app bar) -->
<item name="colorPrimary">#color/bgo_highlight</item>
</style>
Would be grateful for any pointers.

In my code I sent background for decorview for reason to set it for status bar. Maybe you have the same functionality?

Related

Make all views transparent to see only theme background image

I saw a lot of modern beautiful apps in the Play Store that use image as background. I decided to use this solution in my application. I develop for minimum API 21 Android 5.0. I prepared image 1920x1080 for xxhdpi Nexus 5 AVD.
I use material light theme. Here is my modified theme definition xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:background">#drawable/parquet</item>
<item name="android:actionBarStyle">#style/transparentActionBar</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="transparentActionBar" parent="android:Widget.Material.Light.ActionBar">
<item name="android:background">#android:color/transparent</item>
</style>
When I run application I see that each view uses its own scaled copy of theme image. My custom defined style 'transparentActionBar' has no effect on action bar. Only behind status bar I see something like original image. Is it possible to define all views transparency via XML to make visible only screen background image? If no, tell please what is right approach to the solution of this problem.
Regards.
This code does exact what I want
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowBackground">#drawable/parquet</item>
<item name="android:actionBarStyle">#style/ActionBarStyle.Transparent</item>
</style>
<style name="ActionBarStyle.Transparent" parent="android:Widget.Material.Light.ActionBar">
<item name="android:background">#null</item>
</style>

Android Action bar won't obey background color

I've just updated my project to target API 22, and my action bar style appears to have broken. Despite setting the background to white, and the color to blue, I end up with a black action bar with white text.
Here's my application theme.
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:homeAsUpIndicator">#drawable/up_button</item>
<item name="android:actionMenuTextAppearance">#style/H4.Other</item>
<item name="android:actionMenuTextColor">#color/h4_other</item>
<item name="android:windowContentOverlay">#drawable/header_shadow</item>
<item name="android:buttonStyle">#style/ButtonStyle.NoCaps</item>
</style>
Here's my action bar style.
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:title">""</item>
<item name="android:background">#color/white</item>
<item name="android:height">#dimen/action_bar_height</item>
<item name="android:titleTextStyle">#style/H5.Blue</item>
</style>
Ok I figured this out. When you've updated the version of the app compat library you're using, the namespacing of some attributes needs to change. In my case it was changing from android:background to just background, among other things.

How to set background color of android app and background of action bar

I am trying to modify my app to have a dark blue action bar with a light blue background. So far I have only been able to make the entire app dark blue. How can I modify my code to keep the action bar the color it is now but make the background with the team numbers a light blue? Please note my apps minimum API is 14.
I am currently using the following code in my styles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#color/teamLightBlue</item>
</style>
<!-- Activity themes -->
<style name="Theme.Base" parent="android:Theme.Light" />
<style name="Theme.Sample" parent="Theme.Base" />
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="AppTheme">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/teamDarkBlue</item>
</style>
If you choose to use Theme.AppCompat, you can change Action Bar's background color using:
<item name="colorPrimary">#ffffff</item>
but if you choose the Holo one, you can change that color using
<item name="android:colorPrimary">#ffffff</item>
Hope this helps.
As far as I know your code is good instead of Widget.Holo.Light.ActionBar as its not part of AppCompat v7. Use this instead
<style name="CustomActionBarTheme" parent="AppTheme">
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/MyActionBarTheme</item>
<item name="actionBarStyle">#style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/teamDarkBlue</item>
<item name="background">#color/teamDarkBlue</item>
</style>
It should work fine!

Android support library strange theme behavior

since last night I'm expecting this weird behavior of my application theme:
Popup menus appear with black background and AlertDialogs with white text color.
By the way, heres my styles.xml:
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CustomActionBarTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar"
parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/action_bar_background</item>
<!-- Support library compatibility -->
<item name="background">#drawable/action_bar_background</item>
</style>
</resources>
Any idea whats wrong? I just want the popup menu to use the default light theme again and the alert dialog to use a black foreground color.
Why do you think it is wrong?
PopupWindow background is dark in Theme.Light:
<style name="Widget.PopupWindow">
<item name="android:popupBackground">#android:drawable/editbox_dropdown_background_dark</item>
<item name="android:popupAnimationStyle">#android:style/Animation.PopupWindow</item>
</style>
If you want to change it - you need to override popup window style for your theme:
<style name="CustomActionBarTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/MyActionBar</item>
<item name="android:popupWindowStyle">#style/YourCustomStyle</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="YourCustomStyle" parent="#android:style/Widget.PopupWindow">
<item name="android:popupBackground">#drawable/your_background</item>
</style>
Alert dialog gets customized in the same way
OK I solved the problem. I passed the application context to both popup menu and alertdialog builder's constructor. This seems to cause problems with application themes. I simply changed getApplicationContext() to getActivity() and it worked.

Translucent Status Bar Bug

I have a problem with the translucent statusbar only when opening of the app for the first time.
Take a look at the screenshot:
When opening the Navigation Drawer this bug appears, but only on first opening of the app. When I close my app and start it again, everything works fine.
Here is the XML of the Style I use which is including the translucent Status Bar:
<resources>
<!-- Base application theme. -->
<style name="TransTheme" parent="android:Theme.Holo.Light">
<item name="android:windowBackground">#drawable/actionbar_background</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:actionBarStyle">#style/ActionBar.GreenStyle</item>
</style>
<style name="ActionBar.GreenStyle" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/actionbar_background</item>
</style>
</resources>
Add android:fitsSystemWindows="true" as attribute to the ListView of the drawer directly.

Categories

Resources