java 动态切换全屏,非全屏

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 动态切换全屏,非全屏相关的知识,希望对你有一定的参考价值。

Android学习 之 动态切换全屏和非全屏模式
  直接贴出代码:
package com.screen;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
 import android.view.View.OnClickListener;
 import android.widget.Button;
 
 public class MainActivity extends Activity {
 private boolean isFulllScreen = false;
 private Button button;
 
 @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(getResources().getText(R.string.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(getResources().getText(R.string.full_screen));
  WindowManager.LayoutParams params = getWindow().getAttributes();
  params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
  getWindow().setAttributes(params);
  getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  }
 }
 });
  }
}

以上是关于java 动态切换全屏,非全屏的主要内容,如果未能解决你的问题,请参考以下文章

浏览器全屏非全屏切换

Unity发布的WebGL页面应用实现全屏/非全屏切换

Unity发布的WebGL页面应用实现全屏/非全屏切换

非全屏和全屏 UIViewController 之间的漂亮幻灯片过渡

PresentViewController 一个带有 UINavigationController 的非全屏 UIViewController

iphone在非全屏视图中播放视频