Android:自定义标题栏

par*_*666 11 layout android titlebar

我有一个自定义标题栏

 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
 setContentView(R.layout.activities);
 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
Run Code Online (Sandbox Code Playgroud)

哪个工作基本上很好.问题是,在调用上面的代码之前,会显示默认标题栏.我根本不想要一个标题栏,换句话说,在我出现之前不会出现任何标题.

将此添加到清单:

<application android:theme="@android:style/Theme.NoTitleBar">
Run Code Online (Sandbox Code Playgroud)

导致力量关闭.我的清单看起来像这样

<application android:icon="@drawable/icon" android:label="@string/app_name"
    android:theme="@style/My_Theme">
Run Code Online (Sandbox Code Playgroud)

我需要my_Theme,因为它设置了背景颜色,在我的客户主题中设置背景颜色会导致我的彩色背景周围的灰色区域.因此,即使没有力量关闭,我也不确定没有标题会有所帮助.

任何的想法?

谢谢.

Mac*_*rse 14

我和你有同样的问题.

问题在于你的风格.

试试这个:

<?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>
Run Code Online (Sandbox Code Playgroud)

  • 您也可以使用`@android:color / transparent`。 (2认同)