Android:自定义标题栏 [英] Android: Custom Title Bar
问题描述
我有一个自定义标题栏
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activities);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
基本上没问题.问题是,在调用上述代码之前,会显示默认标题栏.我根本不想要标题栏,换句话说,在我的标题栏出现之前,不会出现任何标题.
Which works basically fine. The problem is that until the above code is called the default title bar is shown. I don't want a title bar there at all, in other words before mine shows up no title shall show up.
将此添加到清单:
<application android:theme="@android:style/Theme.NoTitleBar">
导致强制关闭.我的清单看起来像这样
leads to a force close. My manifest looks like this
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:theme="@style/My_Theme">
我需要 my_Theme 的地方,因为它设置了背景颜色,在我的客户主题中设置背景颜色会导致我的彩色背景周围出现灰色区域.因此,即使没有强制关闭,我也不确定无标题是否会有所帮助.
Where I need my_Theme since it sets the background color, setting the background color in my customer theme leads to a gray area around my colored backround. So even without the force close I am not sure if the no title will help.
有什么想法吗?
推荐答案
我和你有同样的问题.
问题在于你的风格.
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="My_Theme">
<item name="android:windowTitleSize">35dp</item>
<item name="android:windowTitleBackgroundStyle">@android:color/black</item>
</style>
</resources>
这篇关于Android:自定义标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!