繁体   English   中英

Android自定义标题栏

[英]Android custom title bar

我一直试图做我的自定义标题栏一个星期。

我已经尝试了大约30个建议来实现这一点,但没有任何效果

我得到you cannot combine custom titles with other title features每次我尝试的时候you cannot combine custom titles with other title features错误you cannot combine custom titles with other title features 我无法摆脱这个错误。 这让我很生气。

我也试图通过在Google上查找错误来找到解决方案。 它也没用。

这是我尝试过的代码:

this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_title);

我不知道如何实现自定义标题栏。

非常感谢提前帮助。

在我看来,这不是最好的方法。

您应该在res / values / styles.xml中执行以下操作:

<style name="AppBaseTheme" parent="...">
    <item name="android:actionBarStyle">@style/mActionBar</item>
</style>

<style name="mActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">...</item>
        <item name="android:icon">...</item>
        <item name="android:titleTextStyle">...</item>
</style>

我最近在实现自定义标题栏时遇到了同样的错误......“你无法将自定义标题与其他标题功能结合起来”

根据您无法将自定义标题与其他标题功能组合 ,如果项目使用Holo主题,则会显示Holo的标题栏。

我删除了所有使用Holo的代码的项目,然后显示了我的自定义标题栏。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM