Android:隐藏顶部状态栏

问题描述 投票:0回答:3

我可以隐藏Android顶部状态栏(出现时间和充电图标)吗?实际上,当我在设备和仿真器上运行事物时,元素的放置有所不同。我想运行我的代码和许多不同的仿真器以进行测试,有帮助吗?

android statusbar
3个回答
1
投票

在Java中是动态的

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

OR

在menifest.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);
}

2
投票

要从Android模拟器中完全删除系统栏(已通过Android 4.0.3测试):

  • 导航到%USER_HOME%\。android \ avd \ avd_name.avd \
  • 编辑config.ini:

    hw.mainKeys =否-关闭系统栏hw.mainKeys =是-开启系统栏


1
投票

尝试这样的事情:

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

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

requestWindowFeature(Window.FEATURE_NO_TITLE)
© www.soinside.com 2019 - 2024. All rights reserved.