12

我建設,應該在Android 2.3的運行一個應用程序,我說都ActionBarSherlock和HoloEverywhere庫。如何在使用ActionBarSherlock時應用HoloEverywhere android主題?

爲了使用ActionBarSherlock我必須使用Theme.Sherlock像這樣:

<application 
    ... 
    android:theme="@style/Theme.Sherlock" 
    ... > 

這是很正常的。

我的主要活動是非常簡單:只是一個5行(我不使用ListAcivity)的ListView。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/menuListView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 

由於它的Android 2.3,我仍然有橙色&黑色主題(除了當然的動作條)。現在我想通過修改我的表現像這樣添加HoloEverywhere主題:

<application 
    ... 
    android:theme="@style/Theme.HoloEverywhereDark.Sherlock" 
    ... > 

但是,這並不能改變什麼......我在想什麼?

+2

我需要像在以前的版本中ICS微調。但我試圖導入ActionBarSherlock和Holoeverywhere。但在導入後在eclipse中拋出很多錯誤。還請告訴我們不能只使用holoeverywhere沒有ActionBarSherlock? – Vins 2012-09-12 10:29:03

+0

哪個錯誤?是的,你可以使用Holoeverywhere without actionbarsherlock – Alexis 2012-09-12 14:07:37

+0

像資源未找到錯誤。我做的導入是 - >文件 - >新建項目 - > Android項目從現有的代碼。 – Vins 2012-09-13 04:11:06

回答

7

要啓用默認爲每個的ListView我在HoloEverywhere庫的styles.xml文件去了河洛主題,然後我加入這行修改了「ListViewStyle」元素:

<item name="android:listSelector">@drawable/list_selector_holo_dark</item> 
+1

是的。好點子。 – 2012-07-27 13:21:00

3

我與ListView的選擇了同樣的問題。我儘管這HoloEveruwhere將默認採用全息選擇器(藍色)(我曾經嘗試都Theme.HoloEverywhereLight和Theme.HoloEverywhereLight),但事實並非如此。也許我錯過了一些東西。

我結束了手動設置選擇:

listView.setSelector(R.drawable.list_selector_holo_light); 

你有你可以利用(list_selector_holo_light爲例)的庫的若干繪圖資源。

+0

這實際上工作,但我必須爲每個ListView做到這一點。 – Alexis 2012-07-27 13:12:08

2

的便攜式和正確的解決方案將從ListViewStyle繼承並覆蓋屬性,在您的styles.xml中進行設置。

如果您在服務器上遠程部署了HoloEverywhere官方庫(例如Maven repo),則無法依賴它保留styles.xml中的更改(您正在根據自己的需要修改它)。

相關問題