transparent activity's full screen on 2.3 - android

I was using this xml style:
<style name="Theme.Transparent" parent="#android:style/Theme.Translucent.NoTitleBar">
This was showing a tansparent layout with full screen, no title bar or status bar on the top in android 2.1 and 2.2.
However, when I tested the application on 2.3, the same activity was showing the home screen status bar on the top (battery etc).
I had to enter these lines to my java code onCreate:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
To get it to remove any status or title bar from the top.
Can anybody shed light why this difference between 2.2 and 2.3?

You can set the theme to:
<style name="Theme.Transparent" parent="#android:style/Theme.Translucent.NoTitleBar.Fullscreen">"
And that should hide both the title bar and fullscreen in every version.

You Can Also Use This
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">

Related

Activity with no Title/Action bar

First off, I'm not completely sure that Title Bar and Action Bar are the same? 2 different things?
I have an existing application that I need to maintain. In I have an activity that had a custom view as a title. What I want is to have the default title bar for the activity - the native one. I removed the custom view, and in the activity class I removed requestWindowFeature(Window.FEATURE_NO_TITLE); but the activity still doesn't show the Title bar. I've set the activity theme to android:theme="#style/Theme.AppCompat.Light". Still no Title Bar.
The activity intent is started with launchActivityForResult - don't know if that has anything to do with that.
What am I missing here? Is there a way to show it programmatically?
title-bar and action-bar is different thing.
use theme like this.
Theme.AppCompat.Light
instead of
Theme.AppCompat.Light.DarkActionBar
<style name="MyMaterialTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
and add this theme to manifest
<application
android:name="com.qwesys.ecommerce.application.AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/MyMaterialTheme">
First off, I'm not completely sure that Title Bar and Action Bar are the same? 2 different things?
Yes these are 2 different things implementation wise. Action Bar is now deprecated and we use something called the toolbar.
https://developer.android.com/reference/android/widget/Toolbar.html
You can make customized toolbar https://developer.android.com/training/appbar/setting-up.html
And for your second part use startActivityForResult() and like suggested by #sagar above you use the theme to to make the toolbar appear.

Show both logo and app name in action bar android

i have set these two lines of code to display both logo and app name in action bar, but only app name appears, like in the screenshot:
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.icon);
Do i need other code to show both? I have added this in manifest but same result:
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:logo="#drawable/icon"
I'm working on a Tabbed activity with action bar.
Can you help me? Thank you
Solved adding
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.icona);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Using logo in actionbar is disabled by default in Android 5.0 Lollipop.
Add these 3 lines in the onCreate(Bundle) method of your Activity class:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.mipmap.ic_launcher4);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Try this one in your style.xml:
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:icon">#drawable/logo</item>
<item name="logo">#drawable/logo</item>
<item name="displayOptions">useLogo|showHome|showTitle</item>
</style>
Don't know whether this makes problems with high api levels but worked for me on API 10.
Did you run you app in emulator or real device? I think on the Design page in the fragment does not show the icon of the app when using the layout of API L or 21.(as show below)
But when you change to API 19 or inflate the fragment into tap, it shows.(as show below)

Action bar icon and label

I want to use an app icon and action bar logo differently. For that, I am able to achieve that, but the concern is the while screen (Activity) is getting loaded and the label is also appearing with the action bar logo, but once the screen (Activity) loaded.
It vanishes as I want. Now I don't want to display that label while the activity is getting loaded. What should I do for that?
One more issue I am facing with the action bar logo is: it's not displaying on a large-screen mobile` (that is, Sony Ericsson Xperia Z (5-inch screen) and Lenovo IdeaPhone K900, 5.5 inch). But for the Samsung devices, it's working fine. What's the issue?
Should I need to write a bunch of lines of code for that or is there a compatibility issue? How can I get rid from this problem?
Use this for the app icon in your manifest:
<application
android:icon="#drawable/launcher"
android:label="#string/app_name"
android:name="com..."
android:theme="#style/Theme"></Application>
And for the action bar icon, create a theme. Something like:
<style name="Theme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:icon">#drawable/icon</item>
</style>

LeftNavBar creates black bar at the top of the activity

I'm trying to incorporate Google's LeftNavBarLibrary into my application. When I load the nav bar I end up with a black bar across the top of the activity. The bar appears to be taking up the space a traditional actionbar would occupy.
Does anyone know where the bar is coming from or how to remove it.
Thanks.
My application theme is slightly customized. Based on the AppCompat theme due to requirements of the MediaRouteActionProvider
styles.xml
<resources>
<style name="AppTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/ab_gradient</item>
</style>
</resources>
The activity pictured above has a custom theme defined in the manifest.
AndroidManifest.xml
<activity
android:name="my.app.namespace.CoreActivity"
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
</activity>
The applications minimum sdk version is 14. So it's not exclusively a Google TV app. I've only been able to test this bug on my Android 4.1 and 4.4 devices.
I deal with the action bar this way:
getActionBar().hide();
Try to put this in your main activity or the activity that is the parent and always present.
Don't bother about the theme in manifest, just set your theme with title bar and hide it through the code.
Hope this helps.
Take a look at: Hide the Status Bar on Android 4.0 and Lower
Notice that this is in the <application> tag. That might help you.
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
or programmatically:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If the Android version is lower than Jellybean, use this call to hide
// the status bar.
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.activity_main);
}
You can set android:windowActionBar style to false by setting custom theme.
Note: In this case getActionBar() will return null. If you remove the action bar using a theme, then the window will not allow the action bar at all.
Thanks for the answers guys. The real issue was actually that the LeftNavBar.java class was creating an artificial margin at the top of the screen. I'd have thought that a google published library would be better than that, but apparently not.

how to disable status bar or notification bar but not disable title bar in android?

I want to disable status bar or notification bar in android. I use android:theme="#android:style/Theme.NoTitleBar.Fullscreen" for disable it but it makes my title bar disable too. how can I only disable status bar?
Make a base activity with below code in onCreate function and extend that activity every time
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Or
you can have above code in every activity for having Title bar visible but status bar invisible.
EDIT: Just make sure you don't define any theme in your Android Manifest.
Use the full screen theme in your manifest and then
You can defined a separate layout with your title in it then use the include tag on every layout in your app.
No Title Bar No Status bar, showing Full Screen Android (Mostly used in Games)
res->values->styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="android:Theme.NoTitleBar.Fullscreen">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
Application Manifest.xml:
:
:
<application android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppBaseTheme"
>
:
:
Result: Full screen without titlebar and status bar
No Title bar showing only Phone status bar
Same file just remove ".Fullscreen"
res->values->styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="android:Theme.NoTitleBar">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
Result: It will show only Status bar without full title bar
Showing Status bar and title bar
res->values->styles.xml:
<style name="AppBaseTheme">
Result:
Try this one in your manifest file:
android:theme="#android:style/Theme.Black.NoTitleBar"

Categories

Resources