[英]Change colour of activated list item background on Honeycomb
For Honeycomb, I have set my listview items to use the ?android:attr/activatedBackgroundIndicator
style so they remain highlighted when selected.对于 Honeycomb,我已将我的列表视图项设置为使用?android:attr/activatedBackgroundIndicator
样式,因此它们在选择时保持突出显示。
How do I change the colour of the highlight?如何更改突出显示的颜色?
Define a custom theme with the item:使用项目定义自定义主题:
<item name="android:activatedBackgroundIndicator">@drawable/my_background</item>
Next, declare that drawable in a state list.xml file under res/drawable/my_background.xml
as illustrated here: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList Make sure that it has an item that responds to android:state_activated="true"
. Next, declare that drawable in a state list.xml file under res/drawable/my_background.xml
as illustrated here: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList Make sure that它有一个响应android:state_activated="true"
的项目。 This is your activated highlight.这是您激活的亮点。
The theme step is optional, (you could use the state list drawable directly if you choose,) but it gives an added layer of flexibility and since you've already defined your ListView items to use that theme attribute you can make this change in one place to affect any Activity that uses the custom theme.主题步骤是可选的,(如果您选择,您可以直接使用 state 列表可绘制,)但它提供了额外的一层灵活性,并且由于您已经定义了 ListView 项目以使用该主题属性,您可以在一个中进行此更改影响任何使用自定义主题的活动的地方。
If you need more info on themes look here: http://developer.android.com/guide/topics/ui/themes.html如果您需要有关主题的更多信息,请查看此处: http://developer.android.com/guide/topics/ui/themes.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.