用行动吧,但没有标题的活动? [英] Activity with action bar but without title?

查看:157
本文介绍了用行动吧,但没有标题的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何实现这一目标?这似乎很简单,但实际上,这并不容易做,在可以接受的方式。我想这样的:

How to achieve this? It seems very simple, but actually it's not easy to do it in acceptable way. I tried this:

1)AndroidManifest我设置活动主题Theme.NoTitleBar。然而,在我的活动,然后getActionBar()方法返回null => UNUSABLE

1) in AndroidManifest I set activity theme to Theme.NoTitleBar. However, in my Activity then getActionBar() method returns null => UNUSABLE

2)我在活动编程隐藏标题致电:

2) I hide title programatically in my activity by calling:

actionbar.setDisplayShowTitleEnabled(false);
actionbar.setDisplayShowHomeEnabled(false);

和它帮助,但有一个小的延迟,这样我就可以看到标题栏也许第二季度的活动推出后,然后消失。它看起来非常蹩​​脚。

and it helped, but there's a little delay, so I can see title bar maybe quarter of second after activity launch, then it disappears. It looks really lame.

是否还有其他选择?

推荐答案

应用自定义主题的活动,是这样的:

Apply a custom theme to your Activity, something like:

<style name="TestTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/TestActionBar</item>
</style>

<style name="TestActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/actionbar_background</item>
    <item name="android:displayOptions"></item>
</style>

这将显示带有徽标的操作栏,但没有标题。

This will show the action bar with the logo, but no title.

这篇关于用行动吧,但没有标题的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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