按钮的多样话 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"
.
更多相关文章
- Android(安卓)禁止横竖屏切换
- android的软键盘的enter键的替换
- android根据字体大小设置控件高度
- TextView、EditText属性简介
- android light
- Android中文API(126) —— Message
- android 权限设置
- 我的android 第三天 - 自定义Toast
- Android(安卓)mqtt入门 Android(安卓)studio