so I have an activity and I want it full screen, display the title bar and the system buttons (back, minimize...). I did take a code from developers.android.com and it does go full screen but when I press my screen, the title pops back and so do the buttons come up and I want it to popup only when I slide my finger up/down on the top/bottom of my screen.
My activity looks like:
package com.example.nsomething.main;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.example.nsomething.R;
public class Report extends Activity {
@TargetApi(Build.VERSION_CODES.KITKAT)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
setContentView(R.layout.report);
initialize();
}
private void initialize() {
Button report = (Button) findViewById(R.id.button1);
report.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(Report.this, Harta.class));
finish();
}
});
}
}
Like the code at official tutorial , you may better to put the code in onWindowFocusChanged .
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.