zoukankan      html  css  js  c++  java
  • Android全屏 去除标题栏和状态栏

     在开发中我们经常需要把我们的应用设置为全屏,这里我所知道的有俩中方法,一中是在代码中设置,另一种方法是在配置文件里改!

      一、在代码中设置:

    01view plaincopy
    02  view plaincopy to clipboardprint?
    03  package com.android.tutor;
    04  import android.app.Activity;
    05  import android.os.Bundle;
    06  import android.view.Window;
    07  import android.view.WindowManager;
    08  public class OpenGl_Lesson1 extends Activity {
    09  public void onCreate(Bundle savedInstanceState) {
    10  super.onCreate(savedInstanceState);
    11  //去除title
    12  requestWindowFeature(Window.FEATURE_NO_TITLE);
    13  //去掉Activity上面的状态栏
    14  getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
    15  WindowManager.LayoutParams. FLAG_FULLSCREEN);
    16  setContentView(R.layout.main);
    17  }
    18  }

    在这里要强调一点,设置全屏的俩段代码必须在setContentView(R.layout.main) 之前,不然会报错.

      二、在配置文件里修改

       (关键代码:android:theme="@android:style/Theme.NoTitleBar.Fullscreen",如果想只是去 除标题栏就后面不用加Fullscreen了,另外,如果想要整个应用都去除标题栏和状态栏,就把这句代码加到<application..标签里 面,如果只是想某个activity起作用,这句代码就加到相应的activity上):

    01<?xml version="1.0" encoding="utf-8"?>
    02  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    03  package="com.android.tutor"
    04  android:versionCode="1"
    05  android:versionName="1.0">
    06  <application android:icon="@drawable/icon" android:label="@string/app_name">
    07  <activity android:name=".OpenGl_Lesson1"
    08  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    09  android:label="@string/app_name">
    10  <intent-filter>
    11  <action android:name="android.intent.action.MAIN" />
    12  <category android:name="android.intent.category.LAUNCHER" />
    13  </intent-filter>
    14  </activity>
    15  </application>
    16  <uses-sdk android:minSdkVersion="7" />
    17  </manifest>

  • 相关阅读:
    with admin option 和 with grant option 的区别 (转)
    压缩数据块
    建表时pctfree和pctused参数作用
    Oracle哪些错误会写进alert日志
    Oracle 差异、增量、零级备份
    模拟原生的promise
    react-loadable 实现组件按需加载
    react 中配置 http-proxy-middleware
    craco 配置 less.module
    ESLint: 'React' was used before it was defined.(no-use-before-define)
  • 原文地址:https://www.cnblogs.com/shihao/p/2713030.html
Copyright © 2011-2022 走看看