Activity Full Screen in Android - android

I am trying to make like Trello application, see in the screenshot of Trello, they covered complete screen with background but still time, network show in title bar, I want to do same in my application such that set background to complete full screen and should show network and time.
I am trying this but it didn't work for me.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
Update

Removing the action bar
You can hide the action bar at runtime by calling hide(). For example:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
https://developer.android.com/guide/topics/ui/actionbar.html
For a translucent system bar (like in trello) see this:
Translucent system bars
You can now make the system bars partially translucent with new
themes, Theme.Holo.NoActionBar.TranslucentDecor and
Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent
system bars, your layout will fill the area behind the system bars, so
you must also enable fitsSystemWindows for the portion of your layout
that should not be covered by the system bars.
If you're creating a custom theme, set one of these themes as the
parent theme or include the windowTranslucentNavigation and
windowTranslucentStatus style properties in your theme.
http://developer.android.com/about/versions/android-4.4.html#UI

try this:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,windowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

Android introduced a Immersive Full Screen Mode concept from Android 4.4, here you can see https://developer.android.com/training/system-ui/immersive.html that solved my problem.

Related

Overlay action bar with a translucent status bar

I'm trying to achieve the effect shown here: http://www.youtube.com/watch?v=6QHkv-bSlds&t=15m48s by Nick and the boys. I can get the action bar to be overlayed, but cannot figure out how to extend this to the status bar. I would also like to know how they managed the transparent black background behind the navigation bar (but this isn't as crucial).
Any help / advice would be greatly appreciated as I currently have no idea how this is done (and am starting to worry it may just be an image rather than an actual implementation).
Edit: i know how to make the bars fully transparent (thats the easy part)! I dont know how to extend the actionbar background to appear behind the now transluscent status bar
I had the same question and found this library: https://github.com/jgilfelt/SystemBarTint
Have a look at line 300 in:
https://github.com/jgilfelt/SystemBarTint/blob/master/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java
setupStatusBarView() Adds a view to the window's decor. This allows you to later set a color/drawable to this view.
If using the SystemBarTint library, the following will allow you to force the status bar to a specified color, which you can then match to your action bar's background:
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintColor(Color.parseColor("#DD000000"));
In this case you would set your action bar's background to: #DD000000
As described in the Android 4.4 APIs:
You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.
If you're creating a custom theme, set one of these themes as the parent theme or include the windowTranslucentNavigation and windowTranslucentStatus style properties in your theme.
In your case (where you want the ActionBar), the second option - including the two new properties into your theme - will give you a translucent Navigation and Status bar.
They are using the new Translucent system bars feature (on Android 4.4 and up).
Translucent system bars
You can now make the system bars partially translucent with new
themes, Theme.Holo.NoActionBar.TranslucentDecor and
Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent
system bars, your layout will fill the area behind the system bars, so
you must also enable fitsSystemWindows for the portion of your layout
that should not be covered by the system bars.
If you're creating a custom theme, set one of these themes as the
parent theme or include the windowTranslucentNavigation and
windowTranslucentStatus style properties in your theme.

Android status bar - can it be transparent?

Can Android status bar be transparent like in iOS? I want it to blend into activity like on iOS. Can it be done and if yes - how?
EDIT: Just to clarify I need to make status bar transparent, not action bar, and yes I know I can completely hide it - but that's not what I'm asking.
No you can't make the system status bar transparent, and shouldn't try to do so in an attempt to mimic iOS:
Don't mimic UI elements from other platforms
Android 4.4 KitKit now allows translucent status and navigation bars:
http://developer.android.com/about/versions/android-4.4.html#UI
For example, you can set the theme as Theme.Holo.NoActionBar.TranslucentDecor.
You can make your activity fullscreen so you won't see the status bar.
Like this :
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
Or set a theme like this
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
It can be done.
Take a look at the following library which basically implements a fading action bar, starting from fully transparent.
https://github.com/ManuelPeinado/FadingActionBar

Indeterminate progress in Android Activity

I am trying to replicate the experience found when you are uninstalling an app in ICS. Specifically the indeterminate progress indicator under the title bar. I have tried using requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS) and the various methods on Activity but to no avail. It instead shows a spinning progress bar in the top right hand corner of the screen/title bar. Am I missing something simple here? Or is this completely custom?
Here is the code I am using:
#Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setProgressBarIndeterminate(true);
setProgressBarIndeterminateVisibility(true);
}
You are using the ActionBar indeterminate progress bar, but you are looking for a ProgressBar View.
You can create the View programmatically or add it to a layout file like --
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminate="true" />
Typically, you can decide when it is shown by calling .setVisibility(View.VISIBLE) to show and .setVisibility(View.GONE) when you are done.
If you have a minimum API of 11 and set your activity or app theme to #android:style/Theme.Holo you will get exactly that ProgressBar shown in your image.
If you want a similar effect on pre-API 11 devices, check out HoloEverywhere
Disclaimer: #iagreen's answer is still the right one -- to get layout similar to the one in uninstall activity your best option is to just use it in a layout, not rely on window features)
But you were on a right track with windows features, you just mixed two of them up.
See, this:
setProgressBarIndeterminate(true);
requests the window's [horizontal] progress bar to be indeterminate. And this:
setProgressBarIndeterminateVisibility(true);
shows the window's indeterminate progress bar -- thing is, it's a completely diffrerent view.
To clarify things further, this gets you a horizontal indeterminate progress bar shown at the top of the window
requestWindowFeature(Window.FEATURE_PROGRESS);
setProgressBarIndeterminate(true);
setProgressBarVisibility(true);
and this gets you a spinner-style progress bar in the actionbar
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
That's a horizontal progress bar in the image, the Action Bar indeterminate progress bar is a Spinner style. You'd either need to make a custom view for the action bar, or put it as a view in your main layout. You can hide the action bar and make a custom header for a particular activity. Just use the Spinner style indeterminate progress bar, it's what everyone expects to see in the Action Bar.

Tabs displayed differently depending on if Theme.NoTitleBar is set or not in the manifest

The tabs are displayed differently depending on if Theme.NoTitleBar is set or not in the manifest. I want the no title bar look when I have a title bar. Any idéa how to achieve that?
I have two images that illustrates the problem.
When NoTitleBar is specified in the manifest the tabs are displayed with icons and text. When NoTitleBar is not specified (and I get a title bar in the app) only text is displayed on the tabs.
That is Theme.Holo, my friend. Try to using Theme.Holo or Theme.Holo.NoActionBar or Theme.Holo.NoActionBar.Fullscreen or whatever you want with Theme.Holo. Have fun!
if you want the original style of your Ui to remain and the title bar to be removed with no effect on that, you have to remove the title bar in your activity's code rather than the manifest. leave the original theme style that you had in the manifest and in each activity that you want no title bar use this.requestWindowFeature(Window.FEATURE_NO_TITLE); in the oncreate() method before setcontentview() like below:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_signup);
...
}

android how to hide the status bar without hiding the title bar

In my application i am working with canvas. I am drawing on canvas. I put canvas color as white. When my app open the canvas is visible along with above status bar.
But i want my canvas should take the full screen. means that Notification status bar should disapear when i run that app bt not the title bar(bcz i m using some custom title bar)
How can i do that?
By using below code i gave custom title,
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
Now i am trying to hide status bar using below code in activity-
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
and in AndroidManifest.xml
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
But it shows force close.
Give me a way how to do that?
It's enough to remove the line
requestWindowFeature(Window.FEATURE_NO_TITLE);
But if you want to display full screen (without action bar) write too
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_location_eb);
You can't use Window.FEATURE_CUSTOM_TITLE after setting Theme.NoTitleBar. It's enough to use just this theme. Do not set all these flags in code.
EDIT: Seems I misunderstood your question. I read it again carefully and now I see you're asking about Android 2.x and its notification bar. Your onCreate() method should look like this:
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.name);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
You mustn't set Theme.NoTitleBar or Theme.NoTitleBar.Fullscreen for this activity. Just use the default Theme or don't specify any theme at all.
Am going to tell you how to tackle the title bar and the system notification panel individually and perfectly.
Use one or both as per Your Need.
1.Do not apply any theme to the Activity through XML.
2.Now, go the corr. Java file and add these lines
inside onCreate()..
after super.onCreate()..
Part.a. to remove just Title Bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Part.b. to remove the System notification panel
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Do not forget to follow them with the usual
setContentView(R.layout.activity_layout_name);

Categories

Resources