【问题标题】:How does one remove the separator line / shadow between status bar and main screen?如何删除状态栏和主屏幕之间的分隔线/阴影?
【发布时间】:2011-06-10 08:50:32
【问题描述】:

在我的应用程序中,我想保留状态栏但使其背景与主屏幕相同。

所以我创建了一个自定义主题来设置应用程序背景:

<resources>
  <style name="Theme.Shelves" parent="android:Theme">
    <item name="android:windowBackground">@drawable/background_shelf</item>
    <item name="android:windowNoTitle">true</item>
  </style>
</resources>

然后放到manifest里面:

 <application android:icon="@drawable/icon" 
              android:theme="@style/Theme.Shelves"
              android:label="@string/app_name">

    <activity android:name=".HelloWorld"
              android:label="@string/app_name">

得到这个:

Screen shot 2 http://i1178.photobucket.com/albums/x370/BinhNguyen84/device.png

除了状态栏和主屏幕之间的分隔线之外,一切都很好。我认为这是因为文本视图填充,所以我将其设置为零但没有任何改变。

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    TextView tv = new TextView(this);
    tv.setText("Hello World");
    setContentView(tv);
    tv.setPadding(0,0,0,0);
}

【问题讨论】:

标签: java android background themes statusbar


【解决方案1】:

从您的屏幕截图来看,“分隔符”实际上是状态栏阴影。我要从这里记忆,但我认为您可以使用以下方法禁用它:

<item name="android:windowContentOverlay">@null</item>

抱歉,如果属性名称稍有错误,正如我所说,从记忆中得到,但我认为它是正确的。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-19
  • 2016-09-24
相关资源
最近更新 更多