<RelativeLayout
android:id="@+id/goods_tab_buy_rl"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/goods_tab_buy_bg" >
<TextView
style="@style/grayText_32px"
android:layout_centerInParent="true"
android:drawableLeft="@drawable/goods_tab_buy_icon"
android:text="兑换"
android:textColor="@drawable/goods_like_text_color" />
android:id="@+id/goods_tab_buy_rl"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/goods_tab_buy_bg" >
<TextView
style="@style/grayText_32px"
android:layout_centerInParent="true"
android:drawableLeft="@drawable/goods_tab_buy_icon"
android:text="兑换"
android:textColor="@drawable/goods_like_text_color" />
</RelativeLayout>
drawable/goods_tab_buy_bg:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/goods_tab_buy_pressed" android:state_pressed="true"></item>
<item android:drawable="@color/white"></item>
</selector>
//代码中设置
Drawable drawable= getResources().getDrawable(R.drawable.drawable);
drawable.setBounds(
0
,
0
, drawable.getMinimumWidth(), drawable.getMinimumHeight());
Textview.setCompoundDrawables(drawable,
null
,
null
,
null
);