android动态全屏切换
2012-08-16 18:52
417 查看
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);
}
}
});
}
}
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);
}
}
});
}
}
相关文章推荐
- Android动态切换全屏和非全屏
- Android 动态切换全屏和非全屏模式
- android动态全屏切换
- (转) Android 全屏控制:动态切换全屏和非全屏
- Android 必知必会 - 动态切换着色模式和全屏模式
- Android 动态切换全屏和非全屏模式
- android动态全屏切换
- android动态全屏切换
- Android 编程下应用全屏和非全屏的动态切换解决方案
- Android编程心得-使用ActionBar+Fragment+ViewPager实现动态切换Menu效果
- Android 主题动态切换框架:Prism
- Android运行时动态全屏以及旋转屏幕时不重新装载
- [Android]动态替换Fragment全屏的问题
- Android 全屏设置和禁止横屏竖屏切换
- android 动态切换主题,动态换肤
- Android实现动态切换横竖屏,保存横竖屏数据(用Preference存储)
- Android 动态设置全屏,退出全屏
- 【译】Android主题动态切换开源库Prism基本原理1-核心库
- Android 全屏界面切换到非全屏界面的问题
- Android中Fragment的动态加载和双屏切换问题