我们都知道在Android中某些功能的实现往往有两种方法:一种是在xml文件中设置相应属性,另一种是用代码实现。同样Android实现全屏显示也可以通过这两种方法实现:

1、在AndroidManifest.xml的配置文件里面的<activity>标签添加属性:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

2、在Activity的onCreate()方法中的super()和setContentView()两个方法之间加入下面两条语句:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏

示例

方法一:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="test.ts.wader.image"

android:versionCode="1"

android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7" />

<application

android:icon="@drawable/ic_launcher"

android:label="@string/app_name" >

<activity

android:label="@string/app_name"

android:name=".ImageListActivity"

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>

</application>

</manifest>



方法二:

public class ImageListActivity extends Activity implements OnItemClickListener {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE); //设置无标题

getWindow().setFlags(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT); //设置全屏

setContentView(R.layout.image_list_layout);

}

}

更多相关文章

  1. Binder驱动的实现
  2. 关于Android(安卓)studio Gradle 实现多渠道打包
  3. 安卓开发中Spinner的基本用法(总结)
  4. android:configChanges属性,横竖屏切换
  5. android带有文字的图片按钮的两种实现方式
  6. 【Android进阶】android:configChanges属性总结
  7. android api Demo之自定义Animation,实现3D旋转效果
  8. Android(安卓)Layout XML属性研究--android:layout_marginBottom
  9. android layout以及一些常用的android控件属性

随机推荐

  1. android studio中如何导入github项目
  2. [置顶] android adapter
  3. Apple IOS、Android、WebOS系统体系架构
  4. Own your Android! Yet Another Universa
  5. [Android] 无线adb调试
  6. Android之TelephonyManager类的方法详解
  7. Android 源码分析-Dalvik 虚拟机创建过程
  8. Android MVP 构架初试
  9. Android 开发热门资料免费下载 110个
  10. Android(安卓)NDK入门