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.
Related
I implemented in my application the (not so) new Appcompat theme with DarkActionBar. Everything works fine, except the popup from hardware menu button (or long press the recent button), that is rendered with white text.
Popup result:
Toolbar: http://i.stack.imgur.com/huWpm.png
Hard menu: http://i.stack.imgur.com/o5fmL.png
I solved an old issue with the popup from Action Mode, adding the actionBarPopupTheme attribute in the app theme. After this, the Hardware Menu popup is also getting the background from actionBarPopupTheme (Ok, we want! Before it was black), but not the textcolor.
The code:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionBarTheme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="actionBarPopupTheme">#style/ThemeOverlay.AppCompat.Light</item>
</style>
<style name="Toolbar" parent="MatchWidth">
<item name="theme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
<item name="android:layout_height">?attr/actionBarSize</item>
<item name="android:background">?attr/colorPrimary</item>
</style>
What is the right way to theme this?
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?
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.
I applied a gradient background to my ActionBar. I can see it in the preview on Eclipse but when I run the app on my phone, the action bar vanishes completely. Why is this happening?
styles.xml
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/AppTheme.ActionBarStyle</item>
</style>
<style name="AppTheme.ActionBarStyle" parent="android:Theme.Holo.Light">
<item name="android:background">#drawable/bg_actionbar</item>
</style>
</resources>
try use to:
Drawable d=getResources().getDrawable(R.drawable.background_image_name);
getActionBar().setBackgroundDrawable(d);
and see this question link
I am currently writing an application for devices on 2.3 - 4.2+ and am having some weird, and unexpected issues. It was working fine until and displaying on all devices before I attempted to theme it. Even with a simple style simply extending the action bar sherlock theme, there appears to be no action bar showing.
The setup for the styles.
<style name="FrameworkRoot.Theme" parent="Theme.Sherlock.Light.DarkActionBar">
<!-- API 11+ (compatibility) -->
<item name="buttonBarStyle">#style/Compat.ButtonBar</item>
<item name="buttonBarButtonStyle">#style/Compat.ButtonBarButton</item>
<item name="indeterminateProgressStyle">#style/Compat.IndeterminateProgress</item>
<!-- API 14+ (compatibility) -->
<item name="listPreferredItemPaddingLeft">#dimen/compat_list_preferred_item_padding_left</item>
<item name="listPreferredItemPaddingRight">#dimen/compat_list_preferred_item_padding_right</item>
<item name="listPreferredItemHeightSmall">#dimen/compat_list_preferred_item_height_small</item>
</style>
<style name="Theme.Base" parent="FrameworkRoot.Theme">
<item name="textHeaderMaxLines">#integer/text_header_max_lines</item>
<item name="trackAbstractMaxLines">#integer/track_abstract_max_lines</item>
<item name="activatableItemBackground">#drawable/activatable_item_background</item>
</style>
<!-- Base themes for the app -->
<style name="Theme.TestApp" parent="Theme.Base">
<item name="actionBarStyle">#style/Widget.TestApp.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.TestApp.ActionBar</item>
</style>
<!-- Base Action Bar Style -->
<style name="Widget.TestApp.ActionBar" parent="Theme.Sherlock.Light.DarkActionBar">
</style>
If I remove the:
<item name="android:actionBarStyle">#style/Widget.TestApp.ActionBar</item>
So that the action bar itself it not getting styled in 3.0+, I can't style the bar.
What would be the best way to set this up? AndroidManifest.xml is pointing the app's style at "Theme.TestApp".
My end goal is to have a custom background on the action bar, as well as custom tab selector colors and fonts. What would be the best way to go about this, as my current method isn't working well.
You have to set an attribute for ActionBarSherlock and the native ActionBar. So replace this for example:
<style name="Theme.Base" parent="FrameworkRoot.Theme">
<item name="textHeaderMaxLines">#integer/text_header_max_lines</item>
<item name="trackAbstractMaxLines">#integer/track_abstract_max_lines</item>
<item name="activatableItemBackground">#drawable/activatable_item_background</item>
</style>
With this:
<style name="Theme.Base" parent="FrameworkRoot.Theme">
<item name="textHeaderMaxLines">#integer/text_header_max_lines</item>
<item name="trackAbstractMaxLines">#integer/track_abstract_max_lines</item>
<item name="activatableItemBackground">#drawable/activatable_item_background</item>
<item name="android:textHeaderMaxLines">#integer/text_header_max_lines</item>
<item name="android:trackAbstractMaxLines">#integer/track_abstract_max_lines</item>
<item name="android:activatableItemBackground">#drawable/activatable_item_background</item>
</style>
The attributes with the 'android' prefix point to the internal resources for the native ActionBar, the attributes without the 'android' in front point to the resources of the ActionBarSherlock.