标签:
收藏按钮制作方法:
1 使用togglebutton
2 制定selector_like.xml 注意togglebutton对应的是state_checked属性
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_selected="true" android:state_pressed="true" android:state_focused="true"
android:drawable="@drawable/like_selected">
</item>
<item android:state_checked="false" android:state_selected="false" android:state_pressed="false" android:state_focused="false"
android:drawable="@drawable/like">
</item>
<item
android:drawable="@drawable/like_selected">
</item>
</selector>
3 给togglebutton添加图片背景,若要使图片置于文字上方,则使用下面的属性
android:drawableTop="@drawable/selector_like"
标签:
原文地址:http://my.oschina.net/yhcocacoder/blog/491251