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?

dor506
  • 5,246
  • 9
  • 44
  • 79

3 Answers3

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.

RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
  • 1
    doesn't work my friend.. how is that different from ? – dor506 Dec 24 '11 at 09:18
  • better to use translucent and nototlebar. – RajaReddy PolamReddy Dec 24 '11 at 09: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 '11 at 09:51
  • both are same, it's working for me, remove the things in onCreate. use only on setting either manifest . – RajaReddy PolamReddy Dec 24 '11 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 '11 at 15:10
  • check this out: https://stackoverflow.com/questions/20862258/android-how-to-get-appcompat-translucent-type-theme-with-support-actionbar – Andy Weinstein Jan 21 '19 at 14:20
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);
Pang
  • 9,564
  • 146
  • 81
  • 122
ramit girdhar
  • 2,272
  • 1
  • 25
  • 26
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);
    }
DeniSHow
  • 1,394
  • 1
  • 18
  • 30