在开发android的应用当中,我们会遇到将一些界面设置为全屏显示的格式,有两种实现的方法。其一是在Java代码中实现,其二是在配置文件中实现。

1. 在Java代码中设置

super.onCreate(savedInstanceState);  requestWindowFeature(Window.FEATURE_NO_TITLE);  //无title  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                WindowManager.LayoutParams.FLAG_FULLSCREEN);  //全屏  setContentView(R.layout.main);  

在这里需要注意的是这两段Java代码必须放在setContentView( ); 之前,不然会报错,错误显示如下。

01-14 05:25:41.429: E/AndroidRuntime(7405): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content 

2. 在Manifest文件中修改

在默认启动的Activity里添加 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 即可

<activity android:name=".MainActivity"            android:label="@string/app_name"            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"            >      <intent-filter>          <action android:name="android.intent.action.MAIN" />          <category android:name="android.intent.category.LAUNCHER" />      </intent-filter>  </activity>

更多相关文章

  1. android Button源码分析
  2. Cocos2d-x3.3RC0加载Android的WebView
  3. Android(安卓)SDK 源代码关联Eclipse
  4. Android(安卓)记住密码功能
  5. Android如何代码混淆
  6. Android(安卓)L下载
  7. Android之ListView中的分割线
  8. [置顶] Android中使用Movie显示gif动态图
  9. 浅谈Java中Collections.sort对List排序的两种方法

随机推荐

  1. html5 video自动播放-Android、IOS video
  2. 总结EditText,TextView使用的点点滴滴
  3. Relative Layout 中用到的一些属性
  4. 在LinearLayout中嵌套RelativeLayout来设
  5. LinearLayout和RelativeLayout 属性对比
  6. Android所有系统资源图标android.R.drawa
  7. android mapView
  8. Android之查看外部依赖jar的源码
  9. Android(安卓)字体和颜色
  10. Android善用预定义样式