安卓:如何禁用FEATURE_NO_TITLE [英] Android: how to disable FEATURE_NO_TITLE

查看:216
本文介绍了安卓:如何禁用FEATURE_NO_TITLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的Andr​​oid应用程序的行为像下面。
1)纵向模式:通过标题栏
2)风景模式:没有(因为身高不限)标题栏

I want my Android application to behave like below. 1) Portrait mode: With title bar 2) Landscape mode: Without title bar (because of height limitation)

我知道我可以使用requestWindowFeature(Window.FEATURE_NO_TITLE实现1)),但
我怎么能动态地从1)2改),当我转动我的电话?

I know I can realize 1) using requestWindowFeature(Window.FEATURE_NO_TITLE), but how can I dynamically change from 1) to 2) when I rotate my phone?

推荐答案

<一个href=\"http://stackoverflow.com/questions/991764/hiding-title-in-a-fullscreen-mode/992060#992060\">This回答提示活动的生命周期中,你不能改变的特征(如发生方向改变时),所以他们建议实现自己的冠军(跳转到 ::编辑:的一部分):

This answer suggests you can't change the feature during the lifecycle of the activity (as happens when the orientation changes), so they recommend implementing your own title (jump to the ":::" part):

<一个href=\"http://stackoverflow.com/questions/991764/hiding-title-in-a-fullscreen-mode/992060#992060\">Hiding标题在全屏模式?

::编辑:

那么,如果你正在尝试动态显示和已经提到的窗口,我不知道,如果你能做到这一点与官方的窗口标题,由于注意活动的生命周期中隐藏它的功能需要被前设置的setContentView()被调用。

Well if you are trying to dynamically show and hide it during the lifetime of the activity I am not sure if you can do that with the official Window Title due to the note that has been mentioned about window features needing to be set before setContentView() is called.

一件事,你可以做的是实现自己的标题栏和动态显示和隐藏...我放在一起这个例子应该设置你O n此正确的轨道

One thing that you could do is implement your own title bar and dynamically show and hide that... I put together this example that should set you o nthe right track

由于当你改变方向,您的应用程序经过一系列生命周期的变化,你必须在的onCreate 一个机会来显示或隐藏的标题。

Since when you change orientation, your app goes through a set of lifecycle changes, you have an opportunity in onCreate to show or hide your title.

http://stuffthathappens.com/blog/2008/11/26/android-lifecycle-triggers-part-2/

或者你干脆指定一个不同的布局风景模式:

Or you specify a different layout altogether for landscape mode:

http://developer.android.com/resources/tutorials/hello- world.html

景观布局

当你想为景观不同的设计,把你的布局XML文件中/ RES /布局的土地。当布局更改Android将自动看这里。如果没有这种特殊的地貌布局定义,Android将伸展的默认布局。

When you want a different design for landscape, put your layout XML file inside /res/layout-land. Android will automatically look here when the layout changes. Without this special landscape layout defined, Android will stretch the default layout.

这篇关于安卓:如何禁用FEATURE_NO_TITLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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