How to keep 4.1 theme & remove TitleBar in Android? - android

When I created new Android application in Eclipse.In its AndroidManifest.xml the theme set to application isandroid:theme="#style/AppTheme"& style.xml is as follows.
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
</resources>
& my screen appears like this.
I want to remove the TitleBar from app but want to show the theme of Android 4.1's.
For this I tried
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar" >
Now my screen appears like this the TitleBar is removed but theme has changed.
Please help me to sort out this issue.

Use this instead : #android:style/Theme.Holo.NoActionBar.

Try out putting this in your manifest.
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"

Related

Activity background in Android

I have an activity with background colour black.
It has edittext and right after soft keyboard goes away, for a moment I see white area under keyboard; and then view gets resized.
This looks like blinking.
Question is, is it possible to set some kind of default background color for entire app? (Assuming that my activity already has background attribute)
windowSoftInputMode is also not an option
If you want to specify the background to your whole application, you may edit the app theme or add custom theme to your application manifest. But this will be overridden when background is specified in the xml layout.
Add custom theme in style.xml
<style name="MyTheme" parent="android:Theme">
<item name="android:background">#android:color/black</item>
</style>
Specify the theme in manifest as
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyTheme" >
Adding theme for each activity in manifest
<activity
android:name=".Login"
android:configChanges="orientation"
android:theme="#style/MyTheme>
</activity>
You can also modify the existing theme in style.xml which is already defined in manifest by changing the background as desired
<item name="android:background">#android:color/black</item>

Why my PreferenceScreen is showing white instead of the default black?

I am testing my app but when I choose settings my preferences screen shows White instead of the default black theme. Just with my app because any other app shows the right black theme in preference screen.
<style name="PreferencesTheme">
<item name="android:background">#000000</item>
</style>
add the above code in value -> styles and
then add
<activity android:name=".Preferrence" android:theme="#android:style/Theme.Black"></activity>
in your manifest file it will solve your problem :)
I guess you using the Light Theme in your AndroidManifest.xml. For those PreferenceActivity set the Theme like this:
<activity
android:name="PreferenceActivity"
android:theme="#android:style/Theme.Holo" >
</activity>

How to set the holo dark theme in a Android app?

How can I set the dark holo theme in my app?
At this time I got this:
<style name="AppTheme" parent="android:Theme.Holo.Light" />
But when I change it to:
<style name="AppTheme" parent="android:Theme.Holo.Dark" />
I get an error error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Dark'.
How to solve the problem?
change parent="android:Theme.Holo.Dark"
to parent="android:Theme.Holo"
The holo dark theme is called Holo
By default android will set Holo to the Dark theme. There is no theme called Holo.Dark, there's only Holo.Light, that's why you are getting the resource not found error.
So just set it to:
<style name="AppTheme" parent="android:Theme.Holo" />
According the android.com, you only need to set it in the AndroidManifest.xml file:
http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme
Adding the theme attribute to your application element worked for me:
--AndroidManifest.xml--
...
<application ...
android:theme="#android:style/Theme.Holo"/>
...
</application>
In your application android manifest file, under the application tag you can try several of these themes.
Replace
<application
android:theme="#style/AppTheme" >
with different themes defined by the android system. They can be like:-
android:theme="#android:style/Theme.Black"
android:theme="#android:style/Theme.DeviceDefault"
android:theme="#android:style/Theme.DeviceDefault.Dialog"
android:theme="#android:style/Theme.Holo"
android:theme="#android:style/Theme.Translucent"
Each of these themes will have a different effect on your application like the DeviceDefault.Dialog will make your application look like a dialog box. You should try more of these. You can have a look from the android sdk or simply use auto complete in Eclipse IDE to explore the various available options.
A correct way to define your own theme would be to edit the styles.xml file present in the resources folder of your application.

How to hide title bar from the beginning

I am using following code to replace title bar.
final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
And it's working fine once UI loaded. Problem is however when I start the app, the ugly gray bar appears for 1-2 seconds until UI loaded. Is there any way to specify not showing the default title bar at all?
If you want the titlebar to be gone in every activity within your app, then add
<application android:name=".YourAppNameHere"
android:label="#string/app_name"
android:icon="#drawable/icon"
android:theme="#android:style/Theme.NoTitleBar">
to your manifest. Not 100% sure though that this will prevent the titlebar from showing up momentarily, but it should work.
In the Manifest file, add this line inside the application tag
android:theme="#android:style/Theme.NoTitleBar"
It will hide the bar from all the activities. If you want to hide it from a specific activity, add the same line to that activity's tag.
Good Luck !
You should add a line to your AndroidManifest which states that you use a theme (standard android or extended)
<application android:name=".YourAppNameHere"
android:label="#string/app_name"
android:icon="#drawable/icon"
android:theme="#style/MyTheme">
and then you can have a themes.xml in your res/values/ folder where you extend the: Theme.NoTitleBar and add custom rules to them (for example like windowBackground)
<resources>
<style name="MyTheme" parent="android:Theme.NoTitleBar">
<item name="android:windowBackground">#drawable/my_background</item>
</style>
<resources>
Have fun

Android - Remove top banner in new application?

Is there a way to remove the banner that appears at the top of my new Android application that has the application name in it? I think I need to do something in the AndroidManifest.xml file, but I'm not sure what to do.
This is actually in the Common Tasks and How to Do Them under the section "Configuring General Window Properties."
[update] as per the comments
Either call...
requestWindowFeature(Window.FEATURE_NO_TITLE);
Or add the following to your Android manifest file...
<application android:icon="#drawable/icon"
android:theme="#android:style/Theme.NoTitleBar">
In file Style.xml:
(App--->src--->main--->res->values--->styles.xml) changes the < resources> to :
<resources>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
</style>
</resources>

Categories

Resources