android:drawableleft 图标居中,RadioButton解决文字和drawableleft和文字一起时不居中

  • Post author:
  • Post category:其他


/**

* 解决文字和drawableleft和文字一起时不居中。要设置 android:background=”@null”android:button=”@null”

* @author zhousheng

*

*/

public class MDMRadioButton extends RadioButton {

public MDMRadioButton(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

// TODO Auto-generated constructor stub

}

public MDMRadioButton(Context context, AttributeSet attrs) {

super(context, attrs);

// TODO Auto-generated constructor stub

}

public MDMRadioButton(Context context) {

super(context);

// TODO Auto-generated constructor stub

}

@Override

protected void onDraw(Canvas canvas) {

//获取设置的图片

Drawable[] drawables = getCompoundDrawables();

if (drawables != null) {