当用户按下 ListView 项目 (android:state_pressed="true") 时,它会闪烁黄色阴影(或者您可以按住)。
这是什么画?我创建了自己的选择器,因为我想要自己的 ListView 项目 color ,但我丢失了按下的颜色。
有一个关于皮肤按钮的 Android 文档引用了#ffff0000,但这会产生红色。
有谁知道它是什么以及如何引用它?
默认的系统资源可以在<android-sdk>/platforms/android-<version>/data/res
。特别是,列表选择器定义在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>
在印刷机上显示的可绘制对象,list_selector_background_transition
,不是单一颜色,而是两个 9 块图像,一个黄色和一个白色,它们之间有动画过渡。
<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)