How to change the whole program’s Skin style?
It can use the specialized apk to implement sharing. But I do not know how to directly use the apk element in the current program.
Could you give me some advice? Thanks!
you can define style for your app.
http://developer.android.com/guide/topics/ui/themes.html
You can define a style that has one of Android theme styles as parent:
<style name="main_style" parent="android:Theme.Black.NoTitleBar">
<item name="android:windowBackground">#drawable/background</item>
<item name="android:cacheColorHint">#00000000</item>
<!-- any other customizations -->
</style>
and then, in your AndroidManifest.xml, apply it the following way
to the activity:
<activity
android:name=".Activity1"
android:theme="#style/main_style"/>
<activity
android:name=".Activity2"
android:theme="#style/main_style"/>
or to your whole application:
<application
android:theme="#style/main_style">
There's no need to define your own theme, you can also use one of stock Android themes:
<application
android:theme="#android:style/Theme.Black.NoTitleBar">
Related
i want to disable the ActionBar in my application, I have been looking for a solution on stackoverflow for quiet a while but nothing helped. My problem is that my custom-theme "NoActionBar" is not used, instead it keeps using "AppBaseTheme" although I changed it in the manifest:
android:theme="#style/NoActionBar"
values-v14 styles:
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="NoActionBar" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
same with values-v11. In values i added this line but I think its not neccessary:
<style name="NoActionBar" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
</style>
I tried to change the parent of NoActionBar, didn't work. I tried to create an extra .xml for "NoActionBar" but that didn't work either because the manifest didn't find it. I tried other tipps from stackoverflow questions but they're pretty outdated.
I know when i put the two "items" within the "AppBaseTheme"-style it works, but I'm pretty sure that is not the proper way to use it?
In a nutshell:
Can somebody please explain to me why its not using my theme? What theme needs which parent? (How would I define multiple themes?)
I hope I explained it properly, I assume the answer is rather simple, sorry in advance for my language mistakes, I'm not native. Thanks!
Edit Manifest:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/NoActionBar" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
You are using your theme but your parent can't be AppBaseTheme, you have to use as parent for example Theme.Holo.NoActionBar or at least a style without action bar.
I know this question has been asked million times but whichever method I use is not good for me.
If I use
android:theme="#android:style/Theme.NoTitleBar"
in the manifest file, the whole theme of the app changes. If I put
requestWindowFeature(Window.FEATURE_NO_TITLE);
in the onCreate activities, it shows up shortly when starting an app.
Btw I don't have any theme selected, just using standard android.
It is unclear what you mean by "whole theme of app changes". For API Level 11+ devices, you probably should be using #android:style/Theme.Holo.NoActionBar.
If you add the theme to the application, it applies to the whole app.
android:theme="#android:style/Theme.NoTitleBar"
You have to add it to the activity declaration.
<activity
android:name=".YourActivity"
android:theme="#android:style/Theme.NoTitleBar"/>
To remove the title bar from your app in android studio
Open res > values > styles.xml file
Replace your code with:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Open your style.xml file, create a new style just like below.
You choose your own name and set the parent as below
<style name="your_own_name" parent="Theme.AppCompat.Light.NoActionBar">
</style>
In your AndroidManifest.xml file, set the theme name for the specific activity you dont want the bar to show and you are done
<activity android:theme ="#style/your_own_name" >
</activity>
This is what worked for me
android:theme="#style/Theme.AppCompat.NoActionBar">
when you create a new project in android then you will get default theme applied on your project, that has title bar. but if you want to remove or apply some other theme for your whole App then you can define like below at application level:
<application
android:name="com.mycomp.myproj.MainApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
but if you want to apply some theme only at some specific screens then you can define like below at activity level:
<activity
android:name="com.mycomp.myproj.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme">
For android 8 and above support. Use this in your app theme file. I've modified my default in res/styles.xml :
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- 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:windowNoTitle">true</item>
<item name="android:background">#color/white</item>
</style>
Inside AndroidManifest
<activity
android:name=".activity.HomeMenu"
android:screenOrientation="nosensor"
android:theme="#android:style/Theme.Light.NoTitleBar">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and make sure your Class extends to Activity
If you have made a custom theme in styles.xml you can do this:
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Override the android colour scheme etc. -->
<item name="android:colorPrimary">#color/color_primary</item>
</style>
To remove the Action bar and title add to styles.xml:
<style name="AppTheme.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
Then in your AndroidManifest.xml you can use your custom theme with or without the action bar
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"> <---- With action bar
<activity
android:theme="#style/AppTheme.NoActionBar"> <---- No action bar
<intent-filter>
etc...
Currently working on migrating to ActionBar in the support libraries. Currently trying to migrate my old themes to inherit from Theme.AppCompat.Light.DarkActionBar but it isn't going very smoothly.
It is fine if I apply the theme in the manifest as such:
<activity
android:name="com.fitsby.LoginActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.DarkActionBar" >
</activity>
But I get a runtime error, stating that LoginActivity(subclass of ActionBarActivity) must have a theme which inherits from Theme.AppCompat, when I do the following:
in styles.xml:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:typeface">sans</item>
</style>
and in the manifest:
<activity
android:name="com.fitsby.LoginActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme" >
</activity>
Any ideas why that is happening? I do not see a problem, since AppTheme clearly inherits from one of the AppCompat Themes.
If you have different values folder in your application, for different API levels, make sure that each of those themes from the folders extend from the required Theme.AppCompat.* themes.
This is so weird.
The best way is to show you a picture:
I've not set any theme or anything like that, so the default one should be used...
Any idea?
Edit: It's the same device!! An android 4.2 emulator.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="es.triiui.myapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="es.triiui.myapp.Activity_EditDetails"
android:label="#string/title_activity_activity__edit_details" >
</activity>
<activity
android:name="es.triiui.myapp.AddNewEntry"
android:label="#string/title_activity_add_new_entry" >
</activity>
<activity
android:name="es.triiui.myapp.ShowDetails"
android:label="#string/title_activity_show_details" >
</activity>
<activity
android:name="es.triiui.myapp.Setpassword"
android:label="#string/title_activity_setpassword" >
</activity>
</application>
(values/styles.xml) is:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
(values-ca/styles.xml) is:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
Both are exactly the same.
Any idea?
Those XML resources you posted are wrong.
In general, themes go in themes.xml (but that shouldn't matter since they're just a style) but more importantly, you don't have a closing </resources> tag (copy/paste error?), nor a namespace definition (xlmns attribute on <resources>).
Both of these should trigger AAPT errors (the missing close tag definitely, the namespace, I'm not sure about - it definitely triggers an Android Lint error!).
Try removing the values-ca/styles.xml file. It will default to values/styles.xml and you shouldn't see any visual changes.
I've not set any theme or anything like that, so the default one
should be used...
From the documentation of android:theme:
If this attribute is not set, the activity inherits the theme set for
the application as a whole — from the <application> element's theme
attribute. If that attribute is also not set, the default system theme
is used
So since you didn't specify a theme it will use the devicedefault theme, therefore the left device uses the holo theme and the right one the pre HC theme.
I'm using ActionBarSherlock to make my app compatible with older devices. The implementation was easy, but now i need to style the default Holo blue line that you see under the tabs to a red line.
I've been reading a few topics (topic 1, topic 2) here on SO and also the ABS doc (link), but i can't get it to work.
This is what i have so far.
In my AndroidManifest.xml i added this line to the application tag.
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" > <!-- SET THE DEFAULT THEME -->
Then in res/values/styles.xml i have:
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
<style name="Theme.MyTheme" parent="Theme.Sherlock">
<item name="actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
</style>
<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#ff000000</item>
<item name="background">#ff000000</item>
</style>
</resources>
But when i run my app, then i still see the default blue line color.
What am i doing wrong?
EDIT
Read this if you want to fully style your ActionBarSherlock!
I found an answer here on SO which gave the following link:
http://jgilfelt.github.com/android-actionbarstylegenerator
It's an easy generator which generates all the needed files for a fully customized ABS! All you have to do is copy the generated files into the appropiate folders and you're set!
Don't forget to enable the style (you'll have to enter a style name in the generator) in your AndroidManifest. For that, see the answer below.
A few things:
You don't really need <style name="AppTheme" parent="android:Theme.Light" /> anymore unless you want to change it to inherit Theme.Sherlock and use it for your app theme. If you decide to do this you will have to use Theme.MyTheme for activities.
Either way, to fix the problem you want to change
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
to
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.MyTheme" >
OR you can apply the theme directly to your activities:
<activity
android:name="com.awesome.package.activity.SomeActivity"
android:theme="#style/Theme.MyTheme"/>
Side note, I recommend this excellent actionbar theme generator
Set in your manifest file theme as follows:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.MyTheme" >
It will preserve all Sherlock themes and will add your custom styles.