1、在开发Android软件时,一般开发的主界面都是没有标题的。在Activity的OnCreate方法中添加代码如下
注意:requestWindowFeature()必须放在setContentView()之后才能起效。2、设置横屏竖屏方法有两种:A、在AndroidManifest.xml文件中添加代码:public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); //设置无标题 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //设置全屏 setContentView(R.layout.main); Button fileOpenBtn = (Button)findViewById(R.id.openFIleBtn); fileOpenBtn.setOnClickListener(new OpenFileAction());
B、在Activity的onResume方法中android:screenOrientation="landscape" //即可landscape设置为横屏portrait设置为竖屏
void onResume() { //设置为横屏 if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }super.onResume(); }