2011-03-03 85 views
0

我看到新的蜂窩有一個畫廊樣本。 並說明了如何通過添加佈局Android honeycomb上的activatedBackgroundIndicator

android:background="?android:attr/activatedBackgroundIndicator" 

您的TextView更改所選文本視圖的色彩

但是我的列表行不僅是文本視圖,但視圖下的集合 線性佈局。

爲了獲得與蜂窩畫廊列表選擇相同的行爲,我厭倦了設置此線性佈局的背景,但它不起作用。所選的行不會將顏色更改爲藍色。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:background=" android:attr/activatedBackgroundIndicator"> 
<BUNCH OF OTHER VIEWS/> 
</LinearLayout> 

感謝先進。

回答

6

您忘記了android:background屬性值前面的?

另請注意,activatedBackgroundIndicator僅適用於Android 3.0及更高版本。

+0

嗨這工作給我謝謝,我們可以更改背景顏色從藍色到其他顏色。 – dharan 2012-06-08 14:18:00

+0

@dharan:是的,通過一個風格資源,儘管我現在沒有一個這樣做的例子。 – CommonsWare 2012-06-08 14:35:47

+3

我可以通過編寫選擇器來實現這個功能,例如<?xml version =「1.0」encoding =「utf-8」?> dharan 2012-06-15 05:39:55