Android实现全屏显示的方法

我们都知道在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. android线性布局控件之间的距离设置
  2. Android中gravity与layout_gravity的区别, Padding 与 margin 区
  3. Android实现全屏显示的方法
  4. Unity与Android(安卓)Studio✨之间那些不清不楚的小秘密✨(Androi
  5. Android中资源文件的Shape使用总结
  6. Android硬件控制之USB连接
  7. Android(安卓)5.1和Android(安卓)5.0相比有哪些变化
  8. Android实现根据条件自动转换手机震动和响铃
  9. Android(安卓)Development

随机推荐

  1. Android(安卓)Studio 3.0以后打包修改文
  2. [Android] 环境优化配置Android(安卓)Stu
  3. Android(安卓)studio maven pom.xml
  4. Android(安卓)启动页,倒计时 view
  5. Android传感器介绍
  6. android图片缩放手势检测类--ScaleGestur
  7. android stdio Error Could not find com
  8. android 开发工具下载地址
  9. Android中自定义Dialog常用的两种方式
  10. android edittext属性说明