[Android]设置Activity为全屏显示的两种方法
2016-07-21 10:36
821 查看
1. 方法1:AndroidManifest.xml 里,Activity的 android:theme 指定为"
@android :style/Theme.NoTitleBar.Fullscreen"
示例:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="
@android :style/Theme.NoTitleBar.Fullscreen">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
2. 方法2: 在onCreate()里指定No title
要加入:
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
示例:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
@android :style/Theme.NoTitleBar.Fullscreen"
示例:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="
@android :style/Theme.NoTitleBar.Fullscreen">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
2. 方法2: 在onCreate()里指定No title
要加入:
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
示例:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
相关文章推荐
- Android RecyclerView使用详解(一)
- Android and js
- Android 权限大全
- java.lang.NullPointerException at android.support.v7.widget.RecyclerView.computeVerticalScrollOffset
- 大牛们是怎么阅读 Android 系统源码的?
- Android Studio 导入第三方jar包的正确姿势
- 记录Android Studio项目提交到github上的出错处理
- 电脑远程连接android手机
- Android文件存储(写入,读取,删除)
- Android 签名之使用命令行给apk签名
- Android Studio新建一个继承其它类的类
- Android串口通信:串口读写实例
- 学习资源
- Android Studio代码补全快捷键设置
- Android 关于.9图片the file is not a PNG
- Android 通用流行框架记录
- Android开发笔记(一百一十三)测试工具
- Android @IntDef的使用 - 代替枚举
- 在第二个页面修改第一个页面listView条目的数据
- AndroidStudio项目提交到github详细步骤