Full screen transparent activity (no title & status bar) doesn't work.... why?
Asked Answered
T

3

13

I'm making a custom lock screen.

The lock screen is an activity which I launch by the time the screen goes off.

However, I can't make the activity be both transparent & fullscreen.

The Status bar keeps showing.

Here's what I do in the manifest:

<activity android:name=".activities.LockScreenActivity"  android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>

I'm also adding these extras in activit's onCreate:

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.lock_screen);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

But it can't seem to work :|

why?

Tuneless answered 24/12, 2011 at 8:45 Comment(0)
G
46

delete the code from onCreate(). use this in Manifestfile.

android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

otherwise create the theme according to your requirement.

Gumdrop answered 24/12, 2011 at 8:59 Comment(6)
doesn't work my friend.. how is that different from <activity android:name=".activities.LockScreenActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/> ?Tuneless
better to use translucent and nototlebar.Gumdrop
Im not sure i follow you. As I said, i wrote in the manifest android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"and you told me to use this in onCreate: setTheme(android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); . Correct me if im wrong, but isn't it the same thing?Tuneless
both are same, it's working for me, remove the things in onCreate. use only on setting either manifest .Gumdrop
very odd. I can't get it to work. When i use "Theme.NoTitleBar.Fullscreen", the status bar is gone.. BUT when i use "Theme.Translucent.NoTitleBar.Fullscreen", The status bar is still there. can u please post the code or add the project which worked for you? thanksTuneless
check this out: #20862758Servitor
B
3

You Need to set flags before setContentView, it should work fine then

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.lock_screen);
Beeline answered 31/7, 2013 at 7:56 Comment(0)
L
0

Here is it link (Hide the Status Bar on Android 4.1 and Higher).

View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();

Hide the Status Bar on Android 4.0 and Lower:

<application
    ...
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
    ...
</application>

@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);
    }
Leonoraleonore answered 21/1, 2016 at 9:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.