dor506
dor506

Reputation: 5414

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

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?

Upvotes: 13

Views: 37850

Answers (3)

DeniSHow
DeniSHow

Reputation: 1414

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);
    }

Upvotes: 0

ramit girdhar
ramit girdhar

Reputation: 2412

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);

Upvotes: 3

RajaReddy PolamReddy
RajaReddy PolamReddy

Reputation: 22493

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.

Upvotes: 46

Related Questions