android编程开发之全屏和退出全屏的实现方法
本文实例讲述了android编程开发之全屏和退出全屏的实现方法。分享给大家供大家参考,具体如下:
xml代码:
<Button android:id="@+id/button5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/fullscreen" android:onClick="changescreen"/>
java代码:
privatestaticbooleanisfull=true;
//全屏设置和退出全屏
privatevoidsetFullScreen(){
//requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
isfull=true;
}
privatevoidquitFullScreen(){
finalWindowManager.LayoutParamsattrs=getWindow().getAttributes();
attrs.flags&=(~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attrs);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
//requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
isfull=false;
}
publicvoidchangescreen(Viewview)
{
if(isfull==true)
{
quitFullScreen();
}
else
{
setFullScreen();
}
}
附加:开始设置无title,全屏
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
//removetitlebar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//fullscreen
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
希望本文所述对大家Android程序设计有所帮助。
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短