怎样的android隐藏状态栏没有隐藏标题栏 [英] android how to hide the status bar without hiding the title bar

查看:151
本文介绍了怎样的android隐藏状态栏没有隐藏标题栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用我工作用帆布。我画在画布上。我把画布颜色为白色。当我的应用程序打开帆布连同上面状态栏可见。 但我想我的画布应采取全屏幕。意味着,通知状态栏应disapear当我运行BT没有标题栏的应用程序(BCZ即时通讯使用一些自定义标题栏) 我怎样才能做到这一点?

In my application i am working with canvas. I am drawing on canvas. I put canvas color as white. When my app open the canvas is visible along with above status bar. But i want my canvas should take the full screen. means that Notification status bar should disapear when i run that app bt not the title bar(bcz i m using some custom title bar) How can i do that?

通过使用以下code,我给自定义标题,

By using below code i gave custom title,

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

现在我试图在活动使用下面code隐藏状态栏 -

Now i am trying to hide status bar using below code in activity-

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

在AndroidManifest.xml中

and in AndroidManifest.xml

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

但它显示了强制关闭。 给我的方式该怎么做?

But it shows force close. Give me a way how to do that?

推荐答案

您无法使用 Window.FEATURE_CUSTOM_TITLE 设置后Theme.NoTitleBar 。这足以只使用这个主题。不要将所有这些标志在code。

You can't use Window.FEATURE_CUSTOM_TITLE after setting Theme.NoTitleBar. It's enough to use just this theme. Do not set all these flags in code.

修改:看来我误解你的问题。我再仔细阅读,现在我明白你问的Andr​​oid 2.x和它的通知栏。你的的onCreate()方法应该是这样的:

EDIT: Seems I misunderstood your question. I read it again carefully and now I see you're asking about Android 2.x and its notification bar. Your onCreate() method should look like this:

public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

    setContentView(R.layout.name);

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

您不能设置 Theme.NoTitleBar Theme.NoTitleBar.Fullscreen 这项活动。只要使用默认的主题或不指定任何主题都没有。

You mustn't set Theme.NoTitleBar or Theme.NoTitleBar.Fullscreen for this activity. Just use the default Theme or don't specify any theme at all.

这篇关于怎样的android隐藏状态栏没有隐藏标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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