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
Related
I am making android app using Visual Studio with the Xamarin platform.
As i read the document the thing I found.
.
As we can see there is only three Theme we can create. So my Question is can we set NoActionBar theme to Application as we can set in Android Studio.
Any Help be Appreciated.
You can use Theme with no Action bar in your app. For ex, you can specify Application Attribute in Properties\AssemblyInfo.cs:
[assembly: Application(Icon = "#drawable/Icon" Theme = "#android:Theme.Holo.Light.NoActionBar")]
Or set it in AndroidManifaset.xml
<application android:theme="#android:style/Theme.Holo.Light.NoActionBar" />
If that does not work, create a style with no action bar, like it's mentioned in here: https://stackoverflow.com/a/14061826/85606
No actionbar with styles
<style name="NoActionBar" parent="#android:style/Theme.Holo.Light.NoActionBar">
</style>
for the last few days I'm trying to implement custom theme, which is created by Action Bar Style Generator to my application. I'm able to use theme with some generic samples from SDK, but I'm not able to use it with my application which uses ActionBarSherlock.
My application with ActionBarSherlock is a modified sample of Tabs and Pager.
Steps which I do:
Create theme with Android Action Bar Style Generator.
Copy theme to res folder inside my application.
Change theme in Manifest file.
After those steps only 'Action bar color' changes to correct one. All other styles are not used in application. I have tried many different approaches which I found online, but without success.
Thank you very much for your help.
Did you add the proper items to your App's theme in styles.xml? You need to use attributes that are NOT prefixed with android:, for example:
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="background">#drawable/bg_striped</item>
<item name="backgroundSplit">#drawable/bg_striped_split</item>
You would also keep the properly prefixed ones for Android versions that have native actionbar.
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:background">#drawable/bg_striped</item>
<item name="android:backgroundSplit">#drawable/bg_striped_split</item>
The best place to understand this is to look at the demo provided with the ActionBarSherlock library project.
I managed to fix the problem.
I missed android:background attribute in TabWidget. This partially
solves the problem.
I had to set setLeftStripDrawable and setRightStripDrawable programatically.
Why is there a difference between theme defined in AndroidManifest.xml and theme taken from styles.xml?
1) AndroidManifest.xml:
<application ... android:theme="#android:style/Theme.Black">
2) AndroidManifest.xml
<application ... android:theme="#style/AppTheme">
styles.xml
<resources>
<style name="AppTheme" parent="#android:style/Theme.Black" />
</resources>
1st setting gives black theme and no action bar. 2nd has dark action bar and light menu.
EDIT : options 1) and 2) - notice Menu and ActionBar
EDIT 2:
Why doesn't the 2nd option actually use the AppTheme (Theme.Black) ? (tested on SGS3)
You probably have another styles.xml file, perhaps under a directory like "values-v11", that is defining the #style/AppTheme differently than #android:style/Theme.Black and taking precedence over the file you're viewing/modifying.
#android:style/Theme.Black implements the exact theme implemented by Android (or device manufacturer). However, #style/AppTheme allows you to perform custom modification in your theme which actually extends the original Theme.Black from android, and in order to perform custom modifications, you use style resources.
In simple words, its just like using Activity class or YourOwnActivity class which extends Activity with extra features inside.
Styles.xml enables you to create your own themes. In AndroidManifest, you set the theme you want for an app or activity. You may want to use a system theme or your own. You can also extend other themes as you're doing setting "parent" attribute. For further information, check this out:
http://developer.android.com/guide/topics/ui/themes.html
You should try to put:
<resources>
<style name="AppTheme" parent="#android:style/Theme.Black" />
</resources>
in a xml file called res/themes.xml
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.
i would like to get rid of the defualt grey bar which apears at the top of my application.
I just can't seem to find the attribute or setting to do so.
how can this be achived?
thanks
Use android:theme="#android:style/Theme.NoTitleBar", either for this specific <activity> element in your manifest, or for the whole <application> element if you want it gone for all of them. Here's a FAQ entry about it.
I tried the manifest method but for some reason it wasn't working.
However using the .java method as described here worked.
requestWindowFeature(Window.FEATURE_NO_TITLE);
Open app/src/main/res/values/styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
A good article why you should avoid removing the title bar from an app by Googler Reto Meier:
http://blog.radioactiveyak.com/2010/07/how-to-display-android-status-bar-in.html
Read and rethink if you really need to remove the title bar from your app.