自定义标题栏 - 系统标题栏带出一个短暂的瞬间? [英] Custom titlebar - system titlebar being shown for a brief moment?

查看:123
本文介绍了自定义标题栏 - 系统标题栏带出一个短暂的瞬间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义布局我想作为我的Andr​​oid应用程序的标题栏来使用。发现该技术(在底部链接)的作品,但系统在标题栏前的onCreate显示()被调用。显然,看起来pretty不和谐,作为一个时刻显示的系统工具栏,然后我的自定义标题栏显示:

I've got a custom layout I want to use as the titlebar of my android app. The technique found (linked at the bottom) works, but the system titlebar is displayed before onCreate() is called. Obviously that looks pretty jarring, as for a moment the system titlebar is shown, then my custom titlebar is shown:

// styles.xml
<resources>
  <style name="MyTheme">
    <item name="android:windowTitleSize">40dip</item>
  </style>
</resources>

// One of my activities, MyTheme is applied to it in the manifest.
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.my_activity);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_header);
}

我总是可以隐藏标题栏的系统,并与每一位可能的布局展示我自己在网上,但是,这不是很友好。

I could always hide the system titlebar and display my own in-line perhaps with each and every layout, but, that's not very friendly.

感谢

HTTP://www.londatiga .NET /它/多么到创建定制的窗口标题,在安卓/

推荐答案

我认为这是一个框架的限制。我在我的一些应用程序有同样的问题,最终的解决方案是由我来告诉框架我不想标题栏在所有的,然后在我的布局创造我自己的。 include指令使得它可以忍受我的,例如:

I think it's a framework limitation. I had the same problem in some of my applications and the ultimate solution was for me to tell the framework I didn't want a title bar at all and then create my own in my layouts. The include directive made it bearable for me, e.g.:

<include layout="@layout/title" />

当我在活动中使用requestWindowFeature(Window.FEATURE_NO_TITLE),我有同样的问题,我想简单地查看系统标题栏,而活性是建立它第一次加载时。

When I used requestWindowFeature(Window.FEATURE_NO_TITLE) in my activities, I would have the same issue, I'd see the system title bar briefly while the activity was being build when it first loaded.

当我转而使用一个主题,告诉框架我不想标题,问题走了,我看现在直接在第一次加载我自己的冠军。造型很容易的:

When I switched to using a theme to tell the framework I didn't want a title, the problem went away and I now see my own title directly on first load. The styling is easy for that:

<style name="FliqTheme" parent="@android:Theme.Black">
    <item name="android:windowNoTitle">true</item>
</style>

我知道这并不适用于您的问题与自定义标题,但像PTC提到的,如果你移动你的自定义标题为风格/主题定义(这你通过覆盖在你的主题系统标题样式),我想你会在正确的轨道上。

I know this doesn't apply to your issue with the custom title, but like ptc mentioned, if you move your custom title into style/theme definitions (which you do by overriding the system title styles in your theme), I think you'll be on the right track.

这篇关于自定义标题栏 - 系统标题栏带出一个短暂的瞬间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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