安卓:隐藏顶部状态栏



我可以隐藏Android顶部状态栏(出现时间和充电图标)吗?实际上,当我在设备和模拟器上运行东西时,元素的定位存在一些差异。我想运行我的代码和许多不同的模拟器进行测试,有什么帮助吗?

要从安卓模拟器中完全删除系统栏(使用安卓4.0.3测试):

  • 导航到 %USER_HOME%\.android\avd\avd_name.avd\
  • 编辑配置.ini :

    hw.mainKeys=no - 关闭系统栏
    hw.mainKeys=yes - 打开系统栏

在 Java 中动态

运行
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);      

在半年期声明.xml喜欢..

Add the following in application if you want to remove it for all the activities in an app:
<application android:theme="@android:style/Theme.Black.NoTitleBar">
Or for a particular activity:
<activity android:theme="@android:style/Theme.Black.NoTitleBar">

编辑:-

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

并在 oncreate() 方法中编写以下内容。

@Override
public void onCreate(android.os.Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);
}

尝试这样的事情:

         <activity android:name=".MainActivity"
            android:label="@string/app_name"  android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
           </activity>

或者在 onCreate 中的 setContentView() 之前执行类似操作

requestWindowFeature(Window.FEATURE_NO_TITLE)

最新更新