国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android實現手寫簽名的操作方法

2020-02-21 17:28:33
字體:
來源:轉載
供稿:網友

隨著移動設備的普及,人們越來越依賴移動設備,這給人們帶來了很多便利,其實我們手寫簽名在一些金融行業得到了廣泛的應用,下面就讓武林技術頻道小編帶大家來了解Android實現手寫簽名的操作方法吧!

package com.****.*****.widget; import android.content.Context;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.Path;import android.util.AttributeSet;import android.view.MotionEvent;import android.view.View; /** * This view implements the drawing canvas. * <p/> * It handles all of the input events and drawing functions. * 簽名版 */public class PaintView extends View { private Paint paint; private Canvas cacheCanvas; private Bitmap cachebBitmap; private Path path; private OnMoveLisener lisener;   public void setSize(int width,int height,OnMoveLisener lisener) {  this.lisener=lisener;  init(width,height); }  public PaintView(Context context, AttributeSet attrs) {  super(context, attrs);  //init(0,0); }  public Bitmap getCachebBitmap() {  return cachebBitmap; }  private void init(int width,int height) {  paint = new Paint();  paint.setAntiAlias(true);  paint.setStrokeWidth(3);  paint.setStyle(Paint.Style.STROKE);  paint.setColor(Color.BLACK);  path = new Path();  cachebBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);  cacheCanvas = new Canvas(cachebBitmap);  cacheCanvas.drawColor(Color.WHITE); }  public void clear() {  if (cacheCanvas != null) {    paint.setColor(Color.WHITE);   cacheCanvas.drawPaint(paint);   paint.setColor(Color.BLACK);   cacheCanvas.drawColor(Color.WHITE);   invalidate();  } }   @Override protected void onDraw(Canvas canvas) {  // canvas.drawColor(BRUSH_COLOR);  canvas.drawBitmap(cachebBitmap, 0, 0, null);  canvas.drawPath(path, paint); }  @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) {   int curW = cachebBitmap != null ? cachebBitmap.getWidth() : 0;  int curH = cachebBitmap != null ? cachebBitmap.getHeight() : 0;  if (curW >= w && curH >= h) {   return;  }   if (curW < w)   curW = w;  if (curH < h)   curH = h;   Bitmap newBitmap = Bitmap.createBitmap(curW, curH, Bitmap.Config.ARGB_8888);  Canvas newCanvas = new Canvas();  newCanvas.setBitmap(newBitmap);  if (cachebBitmap != null) {   newCanvas.drawBitmap(cachebBitmap, 0, 0, null);  }  cachebBitmap = newBitmap;  cacheCanvas = newCanvas; }  private float cur_x, cur_y;  @Override public boolean onTouchEvent(MotionEvent event) {   getParent().requestDisallowInterceptTouchEvent(true);// 通知父控件勿攔截本控件touch事件   float x = event.getX();  float y = event.getY();   switch (event.getAction()) {   case MotionEvent.ACTION_DOWN: {    cur_x = x;    cur_y = y;    path.moveTo(cur_x, cur_y);    break;   }    case MotionEvent.ACTION_MOVE: {    path.quadTo(cur_x, cur_y, x, y);    cur_x = x;    cur_y = y;    lisener.hideWords();//隱藏提醒的文字    break;   }    case MotionEvent.ACTION_UP: {    cacheCanvas.drawPath(path, paint);    path.reset();    break;   }  }   invalidate();   return true; }   public interface OnMoveLisener{  void hideWords();//主界面回調后隱藏提示文字 }}

通過以上的介紹,相信大家已經明了Android實現手寫簽名的操作方法,不過在操作的時候一定要謹慎,選擇有資質的平臺學習還是很重要的,更多的知識盡在武林技術頻道網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 胶州市| 罗田县| 沁水县| 温泉县| 正阳县| 四平市| 娱乐| 黄龙县| 新民市| 剑川县| 商河县| 英吉沙县| 顺义区| 革吉县| 东辽县| 阿尔山市| 南靖县| 黔西县| 同心县| 诸暨市| 江都市| 浮梁县| 沂水县| 兴义市| 商城县| 徐州市| 渭源县| 兴山县| 秀山| 方城县| 云林县| 新巴尔虎左旗| 京山县| 马鞍山市| 太保市| 丰原市| 河池市| 荣成市| 环江| 堆龙德庆县| 务川|