Ugly title bar in android app - android

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>

Related

When trying to use the material theme on Android, my title bar is not using the primary colour

From my research, it appears that when using the material theme on Android the title bar should take on the primary color but for me, it stays black. I know the theme itself is working as things did change to black when I first applied the default(dark) theme. I have this set in the styles.xml file:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>
</resources>
The colors referenced from colors.xml are working as they show up on the s the de in android studio.
I have tried looking for a way to manually change the title bar but I have only found ways to do it programatically and not through layout files. I have attached a pic of what the title bar currently looks like and what i would like it to look like below:
Current title bar
What I want it to look like
Change it to
<style name="AppTheme" parent="android:Theme.Material">
<!-- 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">#color/colorPrimaryDark</item>
</style>

Overlaying the action bar

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>

action bar buttons not taking on background color and can't change background window color

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.

Styling action bar tabs background with AppCompat

I am trying to style background for action bar for versions 2.2 >=. I want to have dark red on title bar and lighter red on tabs. I have similar file placed in values-v11 and values-v14 accordingly. It works as intended on ICS and Kitkat I tested. On 2.x, the color on backgroundStacked appears on both the title bar and tabs.
Why is this happening? I don't want to use Android Asset Studio because I don't want to add extra images if it is possible without.
res/values/styles.xml
<style name="MyAppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="background">#color/dark_red</item>
<item name="backgroundStacked">#color/lighter_red</item>
<item name="titleTextStyle">#style/MyActionBarTabText</item>
</style>
<style name="MyActionBarTabText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>

How to change the overflow icon of the contextual action bar without changing it for the standard action bar?

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>

Categories

Resources