|
|
|
|
<EFBFBD>ڶ<EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>MyRadioButton<EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɡ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>attrs<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>涨<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
|
|
|
|
|
|
<resources>
|
|
|
|
|
|
|
|
|
|
? ? <declare-styleable name="MyRadioButton">
|
|
|
|
|
|
|
|
|
|
? ? ? ? <attr name="drawableTop" format="reference" />
|
|
|
|
|
|
|
|
|
|
? ? </declare-styleable>
|
|
|
|
|
|
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>MyRadioButton<EFBFBD>࣬<EFBFBD>̳<EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>RadioButton
|
|
|
|
|
|
|
|
|
|
public class MyRadioButton extends RadioButton {
|
|
|
|
|
private Drawable drawable;
|
|
|
|
|
public MyRadioButton(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MyRadioButton(Context context, AttributeSet attrs) {
|
|
|
|
|
super(context, attrs);
|
|
|
|
|
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MyRadioButton);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
drawable = typedArray.getDrawable(R.styleable.MyRadioButton_drawableTop);
|
|
|
|
|
drawable.setBounds(0, 0, 60, 60);
|
|
|
|
|
setCompoundDrawables(null, drawable, null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>xml<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
<com.myapp.view.MyRadioButton
|
|
|
|
|
|
|
|
|
|
?????android:id="@+id/rb1"
|
|
|
|
|
|
|
|
|
|
?????android:layout_width="wrap_content"
|
|
|
|
|
|
|
|
|
|
?????android:layout_height="wrap_content"
|
|
|
|
|
|
|
|
|
|
?????android:layout_gravity="center"
|
|
|
|
|
|
|
|
|
|
?????android:layout_weight="1"
|
|
|
|
|
|
|
|
|
|
?????android:button="@null"
|
|
|
|
|
|
|
|
|
|
?????android:gravity="center"
|
|
|
|
|
|
|
|
|
|
?????android:text="<22><><EFBFBD><EFBFBD>1"
|
|
|
|
|
|
|
|
|
|
? ? ?attr:drawableTop="@drawable/<2F><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ͼƬ" />
|
|
|
|
|
|
|
|
|
|
<com.myapp.view.MyRadioButton
|
|
|
|
|
|
|
|
|
|
?????android:id="@+id/rb2"
|
|
|
|
|
|
|
|
|
|
?????android:layout_width="wrap_content"
|
|
|
|
|
|
|
|
|
|
?????android:layout_height="wrap_content"
|
|
|
|
|
|
|
|
|
|
?????android:layout_gravity="center"
|
|
|
|
|
|
|
|
|
|
?????android:layout_weight="1"
|
|
|
|
|
|
|
|
|
|
?????android:button="@null"
|
|
|
|
|
|
|
|
|
|
?????android:gravity="center"
|
|
|
|
|
|
|
|
|
|
?????android:text="<22><><EFBFBD><EFBFBD>2"
|
|
|
|
|
|
|
|
|
|
? ? ?attr:drawableTop="@drawable/-----" />
|
|
|
|
|
|
|
|
|
|
<com.myapp.view.MyRadioButton
|
|
|
|
|
|
|
|
|
|
?????android:id="@+id/rb3"
|
|
|
|
|
|
|
|
|
|
?????android:layout_width="wrap_content"
|
|
|
|
|
|
|
|
|
|
?????android:layout_height="wrap_content"
|
|
|
|
|
|
|
|
|
|
?????android:layout_gravity="center"
|
|
|
|
|
|
|
|
|
|
?????android:layout_weight="1"
|
|
|
|
|
|
|
|
|
|
?????android:button="@null"
|
|
|
|
|
|
|
|
|
|
?????android:gravity="center"
|
|
|
|
|
|
|
|
|
|
?????android:text="<22><><EFBFBD><EFBFBD>3"
|
|
|
|
|
|
|
|
|
|
? ? ?attr:drawableTop="@drawable/----" />
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>RadioGroup<EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD>ѡ<EFBFBD>еڼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊû<EFBFBD>и<EFBFBD>RadioButtonдid<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>һ<EFBFBD>֣<EFBFBD>
|
|
|
|
|
private void initView(){
|
|
|
|
|
Drawable drawable_news = getResources().getDrawable(R.drawable.selector_home_rbtn_news);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ltrb<72>涨<EFBFBD><E6B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
drawable_news.setBounds(0, 0, 50, 50); //<2F><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
rbtn_News.setCompoundDrawables(null, drawable_news, null, null);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD>ǩͼƬ<CDBC><C6AC>С<EFBFBD><D0A1>λ<EFBFBD><CEBB>
|
|
|
|
|
Drawable drawable_live = getResources().getDrawable(R.drawable.selector_home_rbtn_live);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ltrb<72>涨<EFBFBD><E6B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
drawable_live.setBounds(0, 0, 50, 50);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
rbtn_Live.setCompoundDrawables(null, drawable_live, null, null);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD>ǩͼƬ<CDBC><C6AC>С<EFBFBD><D0A1>λ<EFBFBD><CEBB>
|
|
|
|
|
Drawable drawable_tuijian = getResources().getDrawable(R.drawable.selector_home_rbtn_tuijian);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ltrb<72>涨<EFBFBD><E6B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
drawable_tuijian.setBounds(0, 0, 50, 50);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
rbtn_Tuijian.setCompoundDrawables(null, drawable_tuijian, null, null);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD>ǩͼƬ<CDBC><C6AC>С<EFBFBD><D0A1>λ<EFBFBD><CEBB>
|
|
|
|
|
Drawable drawable_me = getResources().getDrawable(R.drawable.selector_home_rbtn_me);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ltrb<72>涨<EFBFBD><E6B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
drawable_me.setBounds(0, 0, 50, 50);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
rbtn_Me.setCompoundDrawables(null, drawable_me, null, null);
|
|
|
|
|
}
|