I'm creating an Android app using the theme "noTitlebar" and all the design changes are done and approved. Now I need to add a menu, so I have to add title bar. But, if I change the theme, the whole design for pop up, border, etc. will be affected.
So I created a custom theme by extending the theme
"android:style/Theme.NoTitleBar".
I enabled the title by
<item name="android:windowNoTitle">false</item>
Now I got the title bar, but menu is showing up. The control is not coming to
public boolean onCreateOptionsMenu(Menu menu) {
How can we enable menu in this theme? Help will be greatly appreciated.
Since your are targeting Honeycomb (right?), when you say titlebar you probably mean Action Bar? Follow the link to read the docs.
In a nutshell:
You need to set targetSdkVersion="11" and your build target (in eclipse) to v11.
Just use Theme.Holo. Action bar is by default enabled. Theme.Holo is a default theme for v11 so you even don't need to define it.
Related
So I created my app to have tabs on the action bar which direct to three fragment windows. I decided to change the theme of the app to "#android:style/Theme.Holo.Light.NoActionBar.Fullscreen" and suddenely my app started crashing with a nullpointer exception. After sometime I realized that the theme change, which disabled the action bar might have caused this.
Is there a way to implement tabbed layout without an action bar? A custom action bar? I badly want to use that theme. OR is there a way to customize the action bar: change the color or add custom icons and search function to make it more visually appealing?
Thank you!
Is there a way to implement tabbed layout without an action bar?
Use ViewPager and any one of several tabbed indicators, such as PagerTabStrip, the TabPageIndicator from the ViewPagerIndicator library, PagerSlidingTabStrip, etc.
Or, use FragmentTabHost.
is there a way to customize the action bar: change the color or add custom icons and search function to make it more visually appealing?
You are responsible for your own icons, so if you do not like your icons, talk to yourself about having yourself come up with better ones.
You can change the color of the action bar via a custom theme, such as one you might set up with Jeff Gilfelt's Action Bar Style Generator. Or, switch to using the appcompat-v7 edition of the action bar (with ActionBarActivity) and you can use a simpler custom theme where you just set some tint values.
as you have not provided code here i think you are using API 21 or less.. so you should change theme of your android application.
change styles.xml file as follows
<resources>
<!-- Base application theme. -->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
I am making a daydream application and I want the settings activity to follow the same interface as the standard settings. For right now I want to make the app use the Holo theme but have a dark action bar like you can get with the Holo.Light.DarkActionBar theme. I've googled around and have not found anything similar, and I tried looking through the android source code to find out how they do it for the Settings page, but it is too big for me to handle and I cannot find the styling system.
I've got my styles set up but I cannot find the correct value to use for actionbar style. I do not have interest in adding more libraries like actionbar sherlock.
NOTE: Dark Action Bar =/= Holo actionbar.
My app only works with 4.2 and up so the Holo.Light.DarkActionBar theme should exist.
For reference, I want my app to have this theme:
The settings app uses the Widget.Holo.ActionBar.Solid for its actionBarStyle. As in:
<style name="Your.Theme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#android:style/Widget.Holo.ActionBar.Solid</item>
</style>
Like a lot of people, I would like to use a custom title bar in android but also use the Holo theme. I've seen a lot of posts recommending using Theme.Holo.NoActionBar but it still gives me the same error as when I change my custom theme to use Theme.Holo. I want to resolve once and for all, is it possible to use a custom title bar like this:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title_bar);
which seems to be the most common way to do it.
Well you can create another element layout which looks like title bar for you and in the current activity you can set requestWindowFeature(Window.FEATURE_NO_TITLE)
This way you get the holo theme aswell as custom title. This is commonly used practice in this scenario.
you can define parent="#android:style/Theme.Holo"
then just disable the windows action bar
like this
<item name="android:windowActionBar">false</item>
in theme.
It's working for me...
I would like to use the default Android Theme.Light in one my activities.
However, when this particular theme is applied in my application Manifest file for the selected activity:
android:theme="#android:style/Theme.Light">
it hides the activity Action Bar.
What needs to be done in java or xml code to preserve the Action Bar, using this particular Light scheme ?
As an alternative, I have used the following default scheme:
android:theme="#android:style/Theme.DeviceDefault.Light">
That scheme does show the activity Action Bar correctly, however some of its objects are not displayed as preferred. In particular, my preference would be to display buttons and spinners as per Theme.Light, but preserve the other style formatting offered by the Theme.DeviceDefault.Light
I would greatly appreciate some tips on how to achieve the above scheme formatting preferences. (I am using SDK = 16).
Why not use "android:style/Theme.Holo.Light" ? is the same but has actionbar it was added in the newer apis
I think you should use Holo.Ligt theme. The old android Theme.Light is not even aware of action bar.
I have the same problem, I like Theme.light's controls, I resolved it like this:
1) define "Theme.Light.ActionBar" in project's styles :
<style name="Theme.Light.ActionBar" parent="#android:style/Theme.Light">
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">true</item>
</style>
2) in the manifest use it :
<activity
android:name="com.your.Activity"
android:theme="#style/Theme.Light.ActionBar" >
I hope that may help
I read http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html but have some issues. For pre-honeycomb I want a custom title, for post-honeycomb I want the default. When I try to run my app on ICS
android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
If I remove the custom title it works fine on all releases, just without the custom title.
in values-v11 I have themes.xml file with this content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="customTheme" parent="android:Theme.Holo.Light">
</style>
</resources>
So my theme document says to use no custom theme basically.
If I remove
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
then the theme shows up correctly on ICS.
I cannot imagine that I have to check on coding level what API level I run and either request the window feature or not, that should be handled by the system.
Thanks, A.
Pretty similar to this question. I guess the action bar is considered a title feature, so turning it off gets rid of the exception.
I'm still a bit confused by the question though. You say you want the default title for post-honeycomb, but you can't use a custom title and also use the default actionbar. If you really want to do what you're asking (custom title for < 3.0, default actionbar for >= 3.0), then you'll need to check Build.VERSION.SDK_INT before calling window.requestFeature etc. That's how it's done in the actionBarCompat example that does just this sort of thing.