没有合适的资源?快使用搜索试试~ 我知道了~
本文为大家分享了Android实现拖动选择按钮的具体代码,供大家参考,具体内容如下 效果图 View代码 第一步:自定义属性 <declare name=DragView> <attr name=icon_drag format=reference/> <attr name=color_circle format=color/> <attr name=dot_num format=integer/> </declare> 第二步:自定义圆形 public class CircleView extends
资源推荐
资源详情
资源评论
Android自定义自定义View实现拖动选择按钮实现拖动选择按钮
本文为大家分享了Android实现拖动选择按钮的具体代码,供大家参考,具体内容如下
效果图效果图
View代码代码
第一步:第一步:自定义属性
<declare-styleable name="DragView">
<attr name="icon_drag" format="reference"/>
<attr name="color_circle" format="color"/>
<attr name="dot_num" format="integer"/>
</declare-styleable>
第二步:第二步:自定义圆形
public class CircleView extends View {
/**
* 默认颜色
*/
private final int DEFAULT_COLOR = Color.LTGRAY;
/**
* 默认半径dp
*/
private final float DEFAULT_RADIUS = 32;
private int mColor;
private Paint mCirclePaint;
private float mRadius;
private float mCenterX;
private float mCenterY;
public CircleView(Context context)
{
this(context, null);
}
public CircleView(Context context, AttributeSet attrs)
{
this(context, attrs, 0);
}
public CircleView(Context context, AttributeSet attrs, int defStyleAttr)
{
super(context, attrs, defStyleAttr);
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.DragView);
mColor = array.getColor(R.styleable.DragView_color_circle,DEFAULT_COLOR);
mCirclePaint = new Paint();
mCirclePaint.setColor(mColor);
mCenterY = mCenterX = mRadius = getMeasuredWidth() == 0?DEFAULT_RADIUS:getMeasuredWidth()/2;
array.recycle();
}
public float getRadius(){
return mRadius;
资源评论
weixin_38692100
- 粉丝: 3
- 资源: 871
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功