android 打卡动画,android音视频打卡(-)3种方法绘制图片

66b52468c121889b900d4956032f1009.png

8种机械键盘轴体对比

本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?

ImageViewtask1Iv.setImageResource(R.mipmap.task1);## SurfaceView ##final Paint paint = new Paint();

final Rect rect = new Rect();

final Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.mipmap.task1);

SurfaceHolder surfaceHolder = surfaceViewTask1.getHolder();

surfaceHolder.addCallback(new SurfaceHolder.Callback() {

@Override

public void surfaceCreated(SurfaceHolder holder) {

surfaceViewTask1.getGlobalVisibleRect(rect);

int measuredWidth = surfaceViewTask1.getMeasuredWidth();

int width = rect.right - rect.left;

Log.e("ccc",measuredWidth+"----"+width);

Surface surface = holder.getSurface();

Canvas canvas = surface.lockCanvas(rect);

canvas.drawBitmap(bitmap,null,rect,paint);

surface.unlockCanvasAndPost(canvas);

surface.release();

}

@Override

public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

}

@Override

public void surfaceDestroyed(SurfaceHolder holder) {

}

});### 扩展surfaceView显示倒计时功能 ###public class Task1CustomSurfaceView extends SurfaceView implements SurfaceHolder.Callback{

private MyThread mThread;

public Task1CustomSurfaceView(Context context) {

this(context,null);

}

public Task1CustomSurfaceView(Context context, AttributeSet attrs) {

this(context, attrs,0);

}

public Task1CustomSurfaceView(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

SurfaceHolder holder = getHolder();

holder.addCallback(this);

}

@Override

public void surfaceCreated(SurfaceHolder holder) {

mThread = new MyThread(holder);

mThread.start();

}

@Override

public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

}

@Override

public void surfaceDestroyed(SurfaceHolder holder) {

}

class MyThread extends Thread{

private Paint mPaint = new Paint();

private SurfaceHolder mHolder;

private DisplayMetrics displayMetrics;

MyThread(SurfaceHolder holder){

this.mHolder = holder;

displayMetrics = getResources().getDisplayMetrics();

}

@Override

public void run() {

try{

for(int i = 0; i<30;i++){ canvas="" canvas.drawcolor(color.white);="" mpaint.setcolor(color.gray);="" mpaint.settextsize(typedvalue.applydimension(typedvalue.complex_unit_sp,16,displaymetrics));="" canvas.drawtext("倒计时:"+(30-i),50,50,mpaint);="" mholder.unlockcanvasandpost(canvas);="" thread.sleep(1000);="" }="" }catch="" (exception="" e){="" <="" pre="">

## 自定义view的方式 ###

public class MyCustomViewForTask1 extends View{

public MyCustomViewForTask1(Context context) {

this(context,null);

}

public MyCustomViewForTask1(Context context,AttributeSet attrs) {

super(context, attrs,0);

}

public MyCustomViewForTask1(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

}

@Override

protected void onDraw(Canvas canvas) {

canvas.drawColor(Color.WHITE);

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.task1);

canvas.drawBitmap(bitmap,0,0,new Paint());

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值