最近在做支付的项目,但是看到美团的支付选择做的比较好,上图,于是我就想照着做出来,可是简单的做,还真没那么容易,于是自己重写了RadioGroup 和 RadioButton,实现效果对比。
美团:我做出的效果:
虽然还是有差距,但是自己做的已经能够自定义布局来展示了,就算再复杂的布局,只需修改部分代码即可了。
下面上一下代码:
1、这是自定义的RadioButton类:
package com.jj.radio;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.Checkable;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class PayRadioPurified extends RelativeLayout implements Checkable {
private ImageView payLogo;
private TextView payTitle;
private TextView payDesc;
private RadioButton payChecked;
private boolean mChecked; 状态是否选中
private boolean mBroadcasting;
private int id;
private OnCheckedChangeListener mOnCheckedChangeWidgetListener;
public PayRadioPurified(Context