I have an activity which displays a fullscreen bitmap image. When the user clicks on the image, the action bar will be hidden. Currently, the bitmap will resize once the action bar is hidden. To address this issue, I have tried overlaying the action bar, as described in the developer guides.
<resources>
<style name="AppTheme" parent="#android:style/Theme.Holo">
<item name="android:homeAsUpIndicator">#drawable/ic_ab_back_holo_dark_am</item>
<item name="android:actionBarStyle">#style/NormalActionBarTheme</item>
</style>
<style name="NormalActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:background">#color/my_green</item>
</style>
</resources>
This displays my solid green action bar, but the windowActionBarOverlay call doesn't seem to do anything- the bitmap will still resize when I hide the action bar.
My minimum sdk is currently set to 16/Jelly Bean/4.1.x, and I am running Lollipop.
What did I do wrong? I appreciate any advice. Thanks!
Set the overlaying option directly to your app's style theme.
<style name="AppTheme" parent="#android:style/Theme.Holo">
<item name="android:homeAsUpIndicator">#drawable/ic_ab_back_holo_dark_am</item>
<item name="android:actionBarStyle">#style/NormalActionBarTheme</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
Related
So I'm experimenting with the new material design (looks gorgeous so far). I implemented "Settings" in the action bar and did a workaround in the resources file for it to work:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">true</item>
</style>
Suddenly, a dark Title bar with the App title appeared, the title in black font (I mean the one with TimetableOrganizer, not the one with Vertretungsplan):
How can I remove this title bar?
That bar is the ActionBar. Remove it by using
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
I'm trying to do what I thought would be simple but after two days of searching for an answer, have given up. I am writing an app and I want the user to be able to switch from the Holo dark theme to the Holo light theme via preferences. Holo Light will be white window background with black text, and Holo dark will be the inverse. I also want them to be able to set the color of the action bar to something they like. Problem I'm having is when I succeed in flipping the background of the main window (by using android:background in styles.xml), the action bar icon and buttons do not take on the color of the action bar. If I use android:windowBackground in styles.xml, the action bar now looks fine and changes color, but the main window background does not. Here is the xml from styles.xml:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="ThemeHoloDark" parent="android:Theme.Holo">
<item name="android:background">#color/background_holo_dark</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:textColor">#0734f9</item>
<!-- blue -->
</style>
<style name="ThemeHoloLight" parent="android:Theme.Holo.Light">
<item name="android:background">#color/background_holo_light</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:textColor">#f90707</item>
</style>
The code I am using to switch theme is this:
if (themeLight == true )
setTheme( R.style.ThemeHoloLight);
else
setTheme( R.style.ThemeHoloDark);
actionBar = getActionBar();
setActionBarTheme(this, actionBar );
Here are some screenshots of what I'm talking about. The first couple show the action bar flipping from light to dark when the preferences are selected:
--Apparently I don't have enough reputation points to post images. :(
I have tried pretty much everything I have found on the web but must be missing something. Any help will be appreciated!
You need to create a seperate custom actionBarStyle like this . android:background in the ActionBarStyle will set the background for action bar.
<style name="ActionBarStyle" parent="android:Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/HoloTitleText</item>
<item name="android:background">#color/Red</item>
</style>
and set it to the main custom style .android:background in the ThemeHoloLight will set the background for window.
<style name="ThemeHoloLight" parent="android:Theme.Holo.Light">
<item name="android:background">#color/DarkGreen</item>
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
You can also change the action bar title color like this
<style name="HoloTitleText" parent="android:TextAppearance.Holo">
<item name="android:textColor">#color/white</item>
</style>
Hope this is what your looking for.
I'm trying to customize a bit my Action Bar, but by doing this, the title in the Action Bar vanish, while the background color correctly change.
Does anyone know where's the problem?
Thank you in advance.
Here is my .xml file:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="AppBaseTheme">
<item name="android:background">#color/ActionBarColor</item>
</style>
</resources>
Your action bar theme should have a parent of #style/Widget.AppCompat.Light.ActionBar, rather than AppBaseTheme.
My app's theme looks like shown in the following screenshot:
As the theme is based on Theme.Holo.Light which contains dark action bar texts and overflow icon, I adjusted the overflow icon using the following style:
<style name="ActionBar.Light" parent="android:style/Widget.Holo.ActionBar">
<item name="android:background">#color/highlight</item>
<item name="android:titleTextStyle">#style/TextAppearance.ActionBar.Title.Light</item>
<item name="android:subtitleTextStyle">#style/TextAppearance.ActionBar.Subtitle.Light</item>
</style>
...
<style name="Theme.Light" parent="#android:style/Theme.Holo.Light">
...
<item name="android:actionBarStyle">#style/ActionBar.Light</item>
<item name="android:actionOverflowButtonStyle">#android:style/Widget.Holo.ActionButton.Overflow</item>
...
</style>
When one or more list entries are checked I want to show a white contextual action bar, but unfortunately the white overflow icon isn't visible on the white background:
Any idea on how to change the overflow icon only for the contextual bar -- either via style or programatically?
Final Workaround (February 27 2014)
It seems as there isn't an option to change the overflow icon of the contextual action bar independent from the one of the standard action bar. So I had no other choice but changing the background color of the contextual bar to a dark gray, to make the white overflow button visible:
The icons on the right are under my control, so it was easy to change them. The "done" icon on the left and the text (check counter) can easily be changed using theme attributes. Only the thin separator between the "done" icon and the check counter cannot be changed using attributes. They would require a custom layout -- that's why I left it how it is for now.
Here's my contextual bar style and the relevant part from the theme:
<style name="TextAppearance.ActionBar.Title" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:fontFamily">sans-serif-light</item>
</style>
<style name="TextAppearance.ActionBar.Title.Light">
<item name="android:textColor">#ffffff</item>
</style>
<style name="ContextualBar.Light" parent="android:style/Widget.Holo.ActionMode">
<item name="android:background">#666666</item>
<item name="android:titleTextStyle">#style/TextAppearance.ActionBar.Title.Light</item>
<item name="android:actionMenuTextColor">#ffffff</item>
</style>
<style name="Theme.Light" parent="#android:style/Theme.Holo.Light">
...
<item name="android:actionBarStyle">#style/ActionBar.Light</item>
<item name="android:actionModeStyle">#style/ContextualBar.Light</item>
<item name="android:actionModeCloseDrawable">#drawable/ic_action_done</item>
<item name="android:actionOverflowButtonStyle">#android:style/Widget.Holo.ActionButton.Overflow</item>
<item name="android:actionMenuTextColor">#ffffff</item>
...
</style>
Ads: You can see the full result in the final app "uPod" which is available at Google play!
On your theme and assuming your using Appcompat
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:actionOverflowButtonStyle">#style/OverFlowStyle</item>
</style>
<style name="OverFlowStyle" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:src">#drawable/your_selector_drawable_here</item>
</style>
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