android要实现全屏的效果,如做游戏开发时全屏,可通过在Activity的setContentView前设置或通过Activity的xml配置来实现
1.Activity中代码实现:
public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐去电池等图标和一切修饰部分(状态栏部分) this.requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐去标题栏(程序的名字) setContentView(R.layout.main); }}
2.在AndroidManifest.xml中定义设置横竖屏
android:theme=”@android:style/Theme.NoTitleBar” 隐去标题栏android:theme=”@android:style/Theme.NoTitleBar.Fullscreen” 隐去状态栏