歡迎您光臨本站 註冊首頁

Android實現簽名塗鴉手寫板

←手機掃碼閱讀     火星人 @ 2020-06-07 , reply:0

本文實例為大家分享了Android實現簽名塗鴉手寫板的具體代碼,供大家參考,具體內容如下

佈局文件


 

//開始簽名

  private void StartSignature() {      // 獲取屏幕尺寸      DisplayMetrics mDisplayMetrics = new DisplayMetrics();      getWindow().getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);    }      @Override    public void onWindowFocusChanged(boolean hasFocus) {      super.onWindowFocusChanged(hasFocus);      if(hasFocus&&mPaintView==null){        int screenWidth = mFl_signature.getMeasuredWidth();        int screenHeight = mFl_signature.getMeasuredHeight();        mPaintView=new PaintView(getApplicationContext(),screenWidth, screenHeight);        mFl_signature.addView(mPaintView);        mPaintView.requestFocus();      }    }

 

//創建簽名文件

  private void createSignFile() {        FileOutputStream fos = null;        File file = null;      try {        path= generateImgePath();        file = new File(path);        fos = new FileOutputStream(file);          //如果設置成        mPaintBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);      } catch (IOException e) {        e.printStackTrace();      } finally {        try {          if (fos != null) {            fos.close();          }          } catch (IOException e) {          e.printStackTrace();        }      }    }

 

//重新簽名

  if (mPaintView.getPath().isEmpty()){            ToastUtils.showShort(this,"您還沒有簽名呦");          }else {            mPaintView.clear();            }


[火星人 ] Android實現簽名塗鴉手寫板已經有498次圍觀

http://coctec.com/docs/android/show-post-237375.html