我希望我的Android应用程序行为如下.
1)人像模式:带标题栏
2)风景模式:没有标题栏(因为高度限制)
我知道我可以实现1)使用requestwindowFeature(Window.FEATURE_NO_Title),但是
当我旋转手机时,如何从1)动态更改为2)?
解决方法:
This answer建议您不能在活动的生命周期中更改该功能(如方向更改时那样),因此他们建议您实现自己的标题(跳转到“:: Edit ::”部分):
Hiding Title in a Fullscreen mode?
::Edit::
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.
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中显示或隐藏您的标题.
http://stuffthathappens.com/blog/2008/11/26/android-lifecycle-triggers-part-2/
或者您为横向模式指定了不同的布局:
http://developer.android.com/resources/tutorials/hello-world.html
总结Landscape layout
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.
以上是内存溢出为你收集整理的Android:如何禁用FEATURE_NO_TITLE全部内容,希望文章能够帮你解决Android:如何禁用FEATURE_NO_TITLE所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)