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?

0

3 Answers 3

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.

6
  • 1
    doesn't work my friend.. how is that different from <activity android:name=".activities.LockScreenActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/> ?
    – dor506
    Dec 24, 2011 at 9:18
  • better to use translucent and nototlebar. Dec 24, 2011 at 9:39
  • 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?
    – dor506
    Dec 24, 2011 at 9:51
  • both are same, it's working for me, remove the things in onCreate. use only on setting either manifest . Dec 24, 2011 at 10:01
  • 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? thanks
    – dor506
    Dec 24, 2011 at 15:10
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);
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);
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.