android银行卡操作步骤

来源:互联网 发布:c语言第四章答案 编辑:程序博客网 时间:2024/04/26 13:24

android银行卡操作步骤

Tag:

项目介绍:

继承View 实现自定义属性(不知道自定义属性的百度)

public BootStepView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);// 加载自定义属性集合BootStepViewTypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BootStepView);// 解析集合中的属性属性// 将解析的属性传入到画圆的画笔颜色变量当中(本质上是自定义画圆画笔的颜色)// 第二个参数是默认设置颜色(即无指定情况下使用)circularColor = typedArray.getColor(R.styleable.BootStepView_circular_color, Color.RED);circularSize=typedArray.getDimensionPixelSize(R.styleable.BootStepView_circular_size,16);circularTextSize=typedArray.getDimensionPixelSize(R.styleable.BootStepView_circular_text_size,60);circularTextColor= typedArray.getColor(R.styleable.BootStepView_circular_text_color, Color.WHITE);....}

在onMeasure()对View的宽高进行测量

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {super.onMeasure(widthMeasureSpec, heightMeasureSpec);// 获取宽-测量规则的模式和大小int widthMode = MeasureSpec.getMode(widthMeasureSpec);int widthSize = MeasureSpec.getSize(widthMeasureSpec);// 获取高-测量规则的模式和大小int heightMode = MeasureSpec.getMode(heightMeasureSpec);int heightSize = MeasureSpec.getSize(heightMeasureSpec);int width=480;int height=240;if (widthMode == MeasureSpec.AT_MOST && heightMode == MeasureSpec.AT_MOST) {setMeasuredDimension(width, height);} else if (widthMode == MeasureSpec.AT_MOST ) {setMeasuredDimension(width, heightSize);}else if(heightMode== MeasureSpec.AT_MOST){setMeasuredDimension(widthSize, height);}}   ## 在onDraw()实现protected void onDraw(Canvas canvas) {super.onDraw(canvas);// 获取传入的padding值final int paddingLeft = getPaddingLeft();final int paddingRight = getPaddingRight();final int paddingTop = getPaddingTop();final int paddingBottom = getPaddingBottom();int width=getWidth();//开始绘制第一个圆int oneX=paddingLeft+circularSize*2;canvas.drawCircle(oneX,paddingTop,circularSize,paint);//开始绘制数字1paint.setColor(circularTextColor);paint.setTextSize(circularTextSize);canvas.drawText("1",oneX-circularTextSize/3,paddingTop+circularTextSize/3,paint);//开始绘制第一个线条paint.setColor(isTwoColor?circularColor:defaultColor);canvas.drawLine(oneX+circularSize,paddingTop,width/2-circularSize,paddingTop,paint);...}

很简单的一个东西,直接附上项目源码下载地址:

点击下载