簡體   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