Cordova 设置全屏及退出全屏切换

设置全屏在super.init();之前
最后才退出全屏。
以下为具体代码:


package com.agile.ittm;

import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import org.apache.cordova.*;

public class ITTM extends CordovaActivity 
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setFullscreen();//设置全屏
        super.init();
        // Set by <content src="index.html" /> in config.xml
       
        super.setIntegerProperty("splashscreen", R.drawable.splash);
        
        super.loadUrl(Config.getStartUrl(), 3000);
        //super.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html")
        quitFullScreen();//退出全屏
    }
    
    //设置全屏
    public void setFullscreen() {  
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);//清除FLAG  
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
                       WindowManager.LayoutParams.FLAG_FULLSCREEN);  
   }  
    //退出全屏
    public void quitFullScreen(){
     final WindowManager.LayoutParams attrs = getWindow().getAttributes();
     attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
     getWindow().setAttributes(attrs);
     getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
     }
    
    
    
}
posted @ 2013-12-04 10:05  zuike  阅读(4808)  评论(0编辑  收藏  举报