首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

旋钮的多样话 selector的使用

2012-09-06 
按钮的多样话 selector的使用?xml version1.0 encodingutf-8??selector xmlns:androidhttp://s

按钮的多样话 selector的使用

<?xml version="1.0" encoding="utf-8"?>
?<selector xmlns:android="http://schemas.android.com/apk/res/android">
? ? ?<item android:drawable="@drawable/button_normal" /> <!-- default -->
? ? ?<item android:state_pressed="true"
? ? ? ? ? ?android:drawable="@drawable/button_pressed" /> <!-- pressed -->
? ? ?<item android:state_focused="true"
? ? ? ? ? ?android:drawable="@drawable/button_focused" /> <!-- focused -->
?</selector>

?

?XML file in your project res/drawable/ folder?

引用 ImageButton ( android:src attribute).

http://developer.android.com/intl/de/reference/android/widget/ImageButton.html

?

http://developer.android.com/intl/fr/reference/android/graphics/drawable/StateListDrawable.html

?styles 不能代码修改 theme可以动态修改

http://developer.android.com/intl/fr/guide/topics/ui/themes.html

res/drawable/my_button.xml

<?xml version="1.0" encoding="utf-8"?>?
<selector xmlns:android="http://schemas.android.com/apk/res/android">?
? <item?
? ? android:state_pressed="true"?
? ? android:drawable="@drawable/btn_pressed" />?
? <item?
? ? android:state_pressed="false"?
? ? android:drawable="@drawable/btn_normal" />?
</selector>?
Button如此设置android:background="@drawable/my_button".

1 楼 lattimore 2010-12-30   有没有搞错!?

热点排行