Android - 使活动全屏显示并在其顶部显示状态栏 [英] Android - Making activity full screen with status bar on top of it

查看:60
本文介绍了Android - 使活动全屏显示并在其顶部显示状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的活动全屏显示,上面有状态栏,就像这张图片:

I want to make my activity full screen with status bar on top of it like this picture:

我在 activity 标签内的 manifest 中使用了此代码:

I have used this code in manifest inside activity tag:

'android:theme="@style/Theme.AppCompat.Light.NoActionBar"'

但是我的视图不是从状态栏开始的 &它看起来像这样:

But my view doesn't start from the status bar & it looks like this:

如何让我的 activity 看起来像第一个?

How can I make my activity look like the first one?

推荐答案

我知道问这个问题的人可能已经找到了自己的解决方案,但对于仍在寻找解决方案的人来说,这是一个非常简单的解决方案,但它在 Kitkat 之前有一个限制,所以添加了一个条件

I know that the guy asking the question may have found his own solution but for the people who are still looking for a solution this is a very simple solution but one thing it has a limitation till Kitkat so a condition is added

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                      WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

这篇关于Android - 使活动全屏显示并在其顶部显示状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆