want to customize view to achieve a RadioButton effect, "post" to add a text how to write? This is part of the content I wrote
needed effect:
Custom view code:
public class MyButton extends android.support.v7.widget.AppCompatRadioButton {
private Paint mPaint;
public MyButton(Context context) {
this(context,null);
}
public MyButton(Context context, AttributeSet attrs) {
super(context, attrs);
Bitmap a=null;
// setBackground(new BitmapDrawable(a));
setButtonDrawable(new BitmapDrawable(a));
mPaint=new Paint();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(0,0);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawText("",0,0,mPaint);
}
}
layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.demo21.MainActivity">
<com.demo21.MyButton
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="center"
android:text="" />
</android.support.constraint.ConstraintLayout>