- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.WindowManager;
- import android.widget.Button;
- public class FullScreenTestActivity extends Activity {
- private Button button;
- private boolean isFulllScreen;
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- button = (Button) findViewById(R.id.button);
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- isFulllScreen = !isFulllScreen;
- if (isFulllScreen) {
- button.setText("exit_full_screen");
- WindowManager.LayoutParams params = getWindow().getAttributes();
- params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
- getWindow().setAttributes(params);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
- } else {
- button.setText("full_screen");
- WindowManager.LayoutParams params = getWindow().getAttributes();
- params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
- getWindow().setAttributes(params);
- getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
- }
- }
- });
- }
- }