什么是默认绘制的pressing列表项 [英] What is the default drawable for pressing a list item
问题描述
当用户presses一个ListView项目。(机器人:STATE_ pressed =真),它闪烁的暗黄色的(或者你可以preSS按住)
When the user presses a ListView item (android:state_pressed="true") it flashes a shade of yellow (or you can press and hold).
什么可绘制的是什么?因为我希望我自己的ListView项的颜色我已经创建了自己的选择,但我失去了pressed颜色。
What drawable is this? I've created my own selector because I want my own ListView item color , but I lose the pressed color.
有关于设置按钮,引用#FFFF0000一个Android文档,但这样会产生红色的。
There's an Android doc about skinning buttons that references #ffff0000, but this produces red.
有谁知道它是什么,以及如何引用它?
Does anyone know what it is and how to reference it?
推荐答案
默认的系统资源可以在&LT发现,Android的SDK> /平台/ android-<版> /数据/ RES
。特别是,该列表选择器中定义绘制/ list_selector_background.xml
:
The default system resources can be found in <android-sdk>/platforms/android-<version>/data/res
. In particular, the list selector is defined in drawable/list_selector_background.xml
:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:drawable="@color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false"
android:state_pressed="true"
android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false"
android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="true"
android:drawable="@drawable/list_selector_background_focus" />
</selector>
这显示在preSS的绘制, list_selector_background_transition
,不是一个单一的颜色,但两个9片图像,黄色和白色的,有它们之间的动画过渡。
The drawable that is shown on a press, list_selector_background_transition
, is not a single color but two 9-patch images, a yellow and a white one, with an animated transition between them.
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:drawable/list_selector_background_pressed" />
<item android:drawable="@android:drawable/list_selector_background_longpress" />
</transition>
这篇关于什么是默认绘制的pressing列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!