I have an old app which now when run on tablets like the Xoom, hides the ActionBar. The app was written before the ActionBar existed so some old code is hiding the actionbar.
What in an old app can hide the ActionBar? I need to change it so that the ActionBar and therefore the menu can be shown:
Here's my very simple Theme:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="android:Theme.Black">
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#android:color/transparent</item>
</style>
<style name="TextViewStyled" parent="#android:style/Widget.TextView">
<item name="android:textStyle">normal</item>
<item name="android:lineSpacingMultiplier">1.22</item>
</style>
</resources>
And here's the only window settings I use:
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_RIGHT_ICON);
Using android:Theme.Black as your theme parent is what's "hiding" the action bar. The Holo and DeviceDefault theme families include an action bar by default, but the legacy theme family (from which Theme.Black derives) does not.
Use a theme declared with the same name "MyTheme" in res/values-v11/themes.xml with a parent of #android:style/Theme.Holo. This version of the theme will be used on devices running API level 11 (Android 3.0, where Holo and the action bar were introduced) or newer. You should similarly use Widget.Holo.TextView instead of Widget.TextView when declaring a custom view style to work within the Holo theme.
Related
I am using custom title bar and its shows content as Theme.light. I tried to change it Theme.Holo but it doesn't work. can anyone help me?
<resources>
<style name="CustomWindowTitleBackground" >
<item name="android:background">#DDDDDD</item>
</style>
<style name="CustomTheme" parent="android:Theme.Holo">
<item name="android:windowTitleSize">73dip</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowTitleBackgroundStyle">#style/CustomWindowTitleBackground</item>
</style>
Provide some more details. Are you using the support action bar? When using the app compat action bar (from the support library) you can only use Theme.AppCompat / Theme.AppCompat.Light and related ones for your activity.
I copied this extract directly from the android online documentation Styling the Action Bar
For Android 3.0 and higher only
When supporting Android 3.0 and higher only, you can define the action bar's background like this:
res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
</style>
</resources>
My minSdk is 11 and yet I'm receiving compatibility warnings at the parent tag. Why?
Theme.Holo.Light.DarkActionBar is only 4.0+, that's why you get the warning. To fix that you can use Holo Light, or change the theme according the the Android version (so you'll have light on Honeycomb and Light with dark actionbar on ICS+).
I want to hide the title bar (where the activity tile is shown) in my application. I'm doing this by setting the android:windowNoTitle item to true. This works fine for devices with API level 19. I tested it with a device running API level 10 and it only hides the notification bar. The tile bar is still shown.
Here is my res/values/styles.xml
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
EDIT: I'm using the AppBaseTheme as the theme in my manifest. There are no other styles.xml files in any other value-vXX folder.
Edit#2: I'm extending an ActionBarActivity for my activity.
try using this
<style name="MyMaterialDialog" parent="Base.Theme.AppCompat.Light.Dialog.MinWidth">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
remove android prefix!
I tried the android:style/Theme.NoTitleBar.Fullscreen in styles.xml but I got:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
So I followed the advise to stick to the AppCompat theme, and could hide statusbar and actionbar using the following lines in styles.xml:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
I use 1 theme for all the devices and it works perfectly on API level 8 to 16 (since I only have 5 physical devices). I'm sure it's working on 17-19 devices too.
Make sure that in your Manifest file (in the application section), there is a line like android:theme="#style/AppTheme"
Try using this for your theme:
<style
name="AppBaseTheme"
parent="android:style/Theme.NoTitleBar.Fullscreen"
>
<item name="android:windowNoTitle">true</item>
...
</style>
And remove the styles/themes in the values-xy folders
[EDIT]
Since the AppCompat theme is NOT full screen, by definition, the StatusBar will go away, but not the TitleBar
If you don't need the ActionBar offered by the AppCompat, then you should get rid of the AppCompat as soon as possible: don't bloat your apps with unneeded and unwanted things
For instance, I have a Header Bar and a Footer Bar, but these are simply RelativeLayouts I implemented my own.
And still have the freedom of using the whole screen surface.
Is there a way to define ActionBar tab style so that it would have different backgrounds when tabs are in ActionBar and below it?
I can't seem to find a way to do that with theme configuration with these properties
<item name="android:actionBarTabStyle">#style/Custom.ActionBar.TabView</item>
<item name="android:actionBarTabBarStyle">#style/Custom.ActionBar.TabBar</item>
<item name="android:actionBarTabTextStyle">#style/Custom.ActionBar.TabText</item>
I can define tab background to be white in #style/Custom.ActionBar.TabBar. All is ok with ActionBar.NAVIGATION_MODE_TABS.
But when I switch to ActionBar.NAVIGATION_MODE_LIST it is placed inside ActionBar and it also becomes white. And thats is unwanted behavior.
You can control the behaviors and visibility of the action bar with the ActionBar APIs, which were added in Android 3.0 (API level 11)."
So, ActionBar will not work for your target environment which is at API level 10 (Android 2.3.3).
Just in case, if you target for minimum API level 11 , you can change ActionBar's background color by defining custom style, as:
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">ANY_HEX_COLOR_CODE</item>
</style>
</resources>
And, set "MyTheme" as theme for application / activity.
Hope this helps...
I am the using the ActionBarSherlock. I have the displayOption "homeAsUp" in my style.xml file. Now this shows a black arrow next to the title of the Activity. Since my theme is White on a blue blackground, i want to change the color of the black arrow, or maybe use a whole new icon resource in its place. How can i do this ?
Kind Regards.
Further to Eric's answer - I wasted a lot of time getting this right.
Remember that these items must go in the parent application theme, inheriting from Theme.Sherlock or similar.
<!-- CUSTOM APP THEME -->
<style name="AppTheme" parent="Theme.Sherlock">
<item name="android:actionBarStyle">#style/AppTheme.ActionBarStyle</item>
<item name="actionBarStyle">#style/AppTheme.ActionBarStyle</item>
<item name="android:homeAsUpIndicator">#drawable/action_bar_ic_ab_back_holo_dark</item>
<item name="homeAsUpIndicator">#drawable/action_bar_ic_ab_back_holo_dark</item>
</style>
Do not put them in the custom Action Bar theme inheriting from Widget.Sherlock.ActionBar.
<!-- ACTION BAR THEME -->
<style name="AppTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar">
<item name="android:icon">#drawable/action_bar_logo</item>
<item name="icon">#drawable/action_bar_logo</item>
<item name="android:displayOptions">showHome</item>
<item name="displayOptions">showHome</item>
</style>
Be careful when you style ActionBarSherlock !
Here is an extract from the web site (ActionBarSherlock Theming):
Due to limitations in Android's theming system any theme customizations must be declared in two attributes. The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation. Since both theming APIs are exactly the same you need only reference your customizations twice rather than having to implement them twice.
So in your case you MUST define two item:
<item name="android:homeAsUpIndicator">#drawable/icon</item>
and
<item name="homeAsUpIndicator">#drawable/icon</item>
Then you are sure that ALL your users will have the same L&F