如何去除状态栏和主屏幕之间的分隔线/阴影?
在我的应用程序中,我想保留状态栏,但使其背景与主屏幕相同。
因此,我创建了一个自定义主题来设置应用程序背景:
<resources>
<style name="Theme.Shelves" parent="android:Theme">
<item name="android:windowBackground">@drawable/background_shelf</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
然后将其放入清单中:
<application android:icon="@drawable/icon"
android:theme="@style/Theme.Shelves"
android:label="@string/app_name">
<activity android:name=".HelloWorld"
android:label="@string/app_name">
并获取此主题:
除了状态栏和主屏幕之间的分隔线之外,一切都很好。我认为这是因为文本视图填充,所以我将其设置为零,但没有任何改变。
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);
}
In my application, I'd like to keep status bar but make its background be the same as the main screen.
So I created a custom theme to set application background:
<resources>
<style name="Theme.Shelves" parent="android:Theme">
<item name="android:windowBackground">@drawable/background_shelf</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
Then put it in 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">
And get this one:
Everything is okay except the separator line between status bar and main screen. I thought that it's because of text view padding, so I set it to zero but nothing changed.
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的屏幕截图来看,“分隔符”实际上是状态栏阴影。我在这里凭记忆,但我认为您可以通过以下方式禁用它:
抱歉,如果属性名称稍有错误,正如我所说,凭记忆,但我认为它是正确的。
Judging by your screenshot the 'seperator' is actually the status bar shadow. I'm going from memory here but I think you can disable it with:
Apologies if the attribute name is slightly wrong, as I say, going from memory but I think it's right.