让我们来看看,
我知道如何改变ListView的风格(当一个项目被选中橙色):
i know how to change the style of a ListView (the orange color when an item is selected):
安卓listSelector =@可绘制/ XXX,并以位图或@Color被拉伸
android:listSelector="@drawable/xxx" and a drawable with a bitmap or a @color
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/image" />
<item android:drawable="@android:color/transparent" />
</selector>
的事情是,为了有一个统一的设计,我必须做同样的事情上下文菜单,但我看不出哪里去改变它。没有listSelector,没有什么改变。
The thing is, in order to have a coherent design, i have to do the same thing for a context menu but i just can't see where to change it. There is no listSelector, nothing to change.
推荐答案
如果通过上下文菜单中你的意思是从长远preSS菜单,然后我跟以下code做到了这一点。我的菜单有我的主题的背景,和一个绿色的亮点。
If by context menu you mean the menu from the long press, then I have done this with the following code. My menu has my theme's background, and a green highlight.
上下文菜单的布局:
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/resetConfirm" android:title="@string/actual_reset"></item>
</menu>
styles.xml,这里我使用的是自定义主题(我认为这是关键)
styles.xml, where I'm using a custom theme (which I think is the key)
<style name="GradientLight" parent="@android:style/Theme.Light">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:progressBarStyle">@style/progressBar</item>
<item name="android:buttonStyle">@style/greenButton</item>
<item name="android:buttonStyleSmall">@style/greenButton</item>
<item name="android:listViewStyle">@style/listView</item>
<item name="android:itemBackground">@drawable/menu_selector</item>
<item name="android:spinnerStyle">@style/spinner</item>
</style>
<style name="listView" parent="@android:style/Widget.ListView.White">
<item name="android:background">@drawable/background</item>
<item name="android:listSelector">@drawable/list_selector_background_green</item>
</style>
相关推荐
最新文章