Android程序进入全屏状态和去掉标题栏

没有过多话,直接贴代码更直观

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

public class GetFullScreenActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 这句要放在 setContentView(R.layout.main);之前,不然会强行关闭的。
        // 去掉标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);       
        setContentView(R.layout.main);
        // 使程序进入全屏状态
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    }
}

你可能感兴趣的:(android,Class,import)