Usa*_*war 2 android android-layout
默认情况下,Android会在点击时显示绿色以显示点按状态.我想将该颜色更改为其他颜色,这样当我在列表视图中的故事被点击时,会显示更改的颜色.
任何帮助表示赞赏.
只需android:listSelector
在ListView中定义属性.
<ListView
android:id="@+id/ListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="@android:color/darker_gray">
</ListView>
Run Code Online (Sandbox Code Playgroud)
根据chirag的评论,我想建议这个链接作为参考:http://developer.android.com/reference/android/R.attr.html#listSelector
只需检查上面链接中的第一行:"Drawable用于指示列表中当前选定的项目."
只需在Drawable文件夹中定义ListSelector xml文件,然后输入以下代码:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/bg_list_item_selected"/>
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/bg_list_item_selected"/>
<item android:state_focused="true" android:drawable="@drawable/bg_list_item_selected"/>
<item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/bg_list_item_normal"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
并将android:background ="@ drawable/listSelctor"提供给自定义列表视图行文件.是的,它是自定义列表视图的自定义列表视图行文件.
归档时间: |
|
查看次数: |
3355 次 |
最近记录: |