标签:
作为selector放在drawable中
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:state_pressed="true" >
<shape android:shape="rectangle">
<gradient
android:startColor="#ff8c00"
android:endColor="#ff8c00"
android:angle="270" />
<corners
android:radius="4dp" />
</shape>
</item>
<!-- focus -->
<item android:state_focused="true" >
<shape>
<gradient
android:startColor="#ffc2b7"
android:endColor="#ffc2b7"
android:angle="270" />
<corners
android:radius="4dp" />
</shape>
</item>
<!-- default -->
<item>
<shape>
<gradient
android:startColor="#d0d0d0"
android:endColor="#d0d0d0"
android:angle="0" />
<corners
android:radius="4dp" />
</shape>
</item>
</selector>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10dip"
android:paddingTop="3dip">
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textColor="@color/light_grey" />
<Button
android:id="@+id/agree"
android:layout_width="wrap_content"
android:layout_height="23dip"
android:layout_toLeftOf="@+id/publish"
android:drawableLeft="@drawable/agree_view"
android:layout_marginRight="10dip"
android:gravity="center"
android:textSize="@dimen/text_size_common"
android:textColor="@color/light_grey"
android:background="@drawable/button_selectort" />
<Button
android:id="@+id/publish"
android:layout_width="wrap_content"
android:layout_height="23dip"
android:layout_alignParentRight="true"
android:drawableLeft="@drawable/reply_view"
android:gravity="center"
android:textSize="@dimen/text_size_common"
android:textColor="@color/light_grey"
android:background="@drawable/button_selector" />
</RelativeLayout>
标签:
原文地址:http://blog.csdn.net/mashihao123/article/details/51353663