我正在使用操作欄sherlock。我有一個透明像素的圖標。但是當我運行我的應用程序時,似乎「某種東西」將主題背景替換爲這些透明像素,而不是操作欄背景。操作欄填充背景錯誤的透明圖標像素
如果主背景被指定爲@color或@drawable(9 patch),但在後一種情況下(這是我真正想要的),沒關係,還有一個額外的怪癖,那就是幾個像素點主背景9補丁出現在操作欄的右側(!)手邊。去搞清楚。
我不知道這裏發生了什麼。只是,如果我從主風格中刪除背景項目,操作欄看起來應該是這樣(所以這似乎是問題)。
有沒有其他人見過這樣的行爲?謝謝參觀!
我會粘貼下面我style.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ViewPagerIndicator">
<attr name="vpiSubTabPageIndicatorStyle" format="reference"/>
</declare-styleable>
<style name="Theme.StandBy" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicator</item>
<item name="vpiSubTabPageIndicatorStyle">@style/CustomSubTabPageIndicator</item>
<item name="android:actionBarStyle">@style/Theme.StandBy.App.ActionBar</item>
<item name="actionBarStyle">@style/Theme.StandBy.App.ActionBar</item>
<!-- ------------------------------------------ ->
<!-- I tried both of these, but can't get transparent pixels in my icon to work --->
<!-- when I use the 9 patch (frg_background) in stead of a plain color, there -->
<!-- are extra artefacts in that some of the 9 patch pixels end up on the righthand -->
<!-- side of the action bar -->
<!--<item name="android:background">@drawable/frg_background</item>
<item name="background">@drawable/frg_background</item>-->
<item name="android:background">@color/cream</item>
<item name="background">@color/cream</item>
<!-- ------------------------------------------ ->
</style>
<style name="Theme.StandBySubTab" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="vpiTabPageIndicatorStyle">@style/CustomSubTabPageIndicator</item>
</style>
<style name="Theme.StandBy.App.ActionBar" parent="Widget.Sherlock.ActionBar">
<!--
Both `android:xyz` and `xyz` need to be set to support 4.x and 2.x devices.
-->
<item name="android:displayOptions">showHome</item>
<item name="displayOptions">showHome</item>
<item name="android:background">@drawable/bar</item>
<item name="background">@drawable/bar</item>
</style>
<!-- top tab style -->
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:background">@drawable/tab_background</item>
<item name="android:textAppearance">@style/CustomTabPageIndicator.Text</item>
<item name="android:divider">@drawable/tab_divider</item>
<item name="android:showDividers">middle</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
</style>
<style name="CustomTabPageIndicator.Text">
<item name="android:textColor">@color/tab_text</item>
<item name="android:textSize">10sp</item>
<item name="android:textStyle">bold</item>
</style>
<!-- sub tab style -->
<style name="CustomSubTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:background">@drawable/sub_background</item>
<item name="android:textAppearance">@style/CustomSubTabPageIndicator.Text</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
</style>
<style name="CustomSubTabPageIndicator.Text">
<item name="android:textColor">@color/sub_text</item>
<item name="android:textSize">10sp</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
編輯:既然問題消失,如果我沒有在我的主要風格指定background
和android:background
(Theme.StandBy),它發生在我,我可能會問錯誤的問題。我將這些項目放入的目的是爲我的所有片段(選項卡的內容)指定默認背景。這有效,但有我上面提到的不需要的副作用。我應該以另一種方式來做這件事嗎?感謝您的任何建議!
我沒有答案,但只是fyi Google昨天發佈了ActionBarCompat,它是一個將Action欄降至api 7的庫。 - https://www.youtube.com/watch?v=6TGgYqfJnyc – Shmuel
謝謝!這會讓sherlock,也可能是我的問題消失。我會盡快嘗試(儘管我沒有多少使用sherlock的投訴,我應該補充)。但感覺,我認爲我只是在做一些非常愚蠢的事情,這可能仍然不能用於ActionBarCompat ... –
每個David的建議我已經刪除了sherlock而贊成谷歌自己的support-v7-appcompat。正如我擔心的那樣,問題仍然存在。 –