And*_*rew 11 android state selector
当用户按下ListView项目(android:state_pressed ="true")时,它会闪烁一个黄色的阴影(或者你可以按住).
这有什么可吸引人的?我已经创建了自己的选择器,因为我想要自己的ListView项目颜色,但是我失去了按下的颜色.
有一个关于皮肤按钮的Android文档引用了#ffff0000,但这会产生红色.
有谁知道它是什么以及如何引用它?
Jon*_*nas 36
可以在中找到默认系统资源<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>
Run Code Online (Sandbox Code Playgroud)
印刷机上显示的可绘制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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14713 次 |
| 最近记录: |