自定义标题栏在启动时仍显示原始内容
我在我的应用程序中使用自定义标题栏,一切正常,除了当应用程序启动时,原始(标准)android 标题栏会显示一小段时间,然后被我的自定义标题栏替换。
当应用程序已加载到内存中时,这不是问题,因为“延迟”并不明显,但如果应用程序尚未加载到内存中,则非常明显。
代码没有什么特别的:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
我考虑过将样式更改为没有窗口标题,而只是在布局顶部包含我的自定义标题,但这似乎不对。
感谢您的指点。
I'm using a custom title bar in my app and it all works fine except that when the app starts up, the original (standard) android title bar is shown for a brief time before it is replaced by my custom title bar.
This is not a problem when the app is already loaded in memory because the 'delay' is not apparent but if the app is not already in memory, it is very obvious.
There's nothing special about the code :
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
I thought about changing the style to have no window title and just include my custom title in the top of the layout but that doesn't seem right.
Thanks for any pointers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Thomas Devaux 发布了一个智能解决方案。它在我的应用程序中有效
Thomas Devaux has posted a smart solution. It worked in my app
为了使 Lluis 的答案完整,以下是在启动自定义标题之前隐藏默认标题所需的完整代码:
For completeness to Lluis' answer, here's the full code you need to hide the default-title before the custom-title is initiated:
在主活动加载之前添加启动屏幕活动,应该有足够的时间让下一个活动正确加载
add a splash screen activity before the main activity loads, should have enough time for the next one to load properly
您是否可以使用应用程序主题为您的应用程序全局设置自定义标题? 请参阅此处以获得一个很好的示例。我遇到了类似的问题,我似乎记得走这条路线解决了它。
Are you able to use an app theme to set a custom title globally for your app? See here for a pretty good example. I had a similar problem and i seem to remember going this route fixed it.