全屏与退出全屏

1 java代码,设置全屏显示

 

    //全屏
	public void setFullScreen( View  view){
	     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}
	
	//退出全屏
	public void quitFullScreen(View  view){
	      final WindowManager.LayoutParams attrs = getWindow().getAttributes();
	      attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
	      getWindow().setAttributes(attrs);
	      getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
	  }

 

 

 

 

2 xml设置  

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
 
        <Button
            android:id="@+id/main_button_full"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:onClick="setFullScreen"
            android:text="全屏" />
        
        <Button
            android:id="@+id/main_button_quit_full"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:onClick="quitFullScreen"
            android:text="退出全屏" />
         
</LinearLayout>

 

你可能感兴趣的:(退出)