0

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

4

3 回答 3

3

从 Android Emulator 中完全删除系统栏(使用 Android 4.0.3 测试):

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

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

于 2013-01-29T12:05:18.040 回答
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)
于 2012-10-04T06:21:00.110 回答
1

在 Java 中动态地

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

或者

在 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);
}
于 2012-10-04T06:23:14.940 回答