苹果签名

iphoneqm
首页 > 苹果签名 > 正文内容

android 画布实现签名,Android实现屏幕手写签名

admin1年前 (2024-12-19)苹果签名359

  Android屏幕手写签名的原理就是把手机屏幕当作画板,把用户手指当作画笔,手指在屏幕上在屏幕上划来划去,屏幕就会显示手指的移动轨迹,就像画笔在画板上写字一样。实现手写签名需要结合绘图的路径工具Path,在有按下动作时调用Path对象的moveTo方法,将路径起始点移动到触摸点;在有移动操作时调用Path对象的quadTo方法,将记录本次触摸点与上次触摸点之间的路径;在有移动操作与提起动作时调用Canvas对象的drawPath方法,将本次触摸绘制在画布上。

android 画布实现签名,Android实现屏幕手写签名

  layout/activity_signature.xml界面布局代码如下:

  xmlns:app="://schemas.android/apk/res-auto"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:orientation="vertical"

  android:padding="5dp">

  android:layout_width="match_parent"

  android:layout_height="wrap_content">

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="vertical">

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="horizontal">

  android:id="@+id/btn_add_signature"

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:text="开始签名"

  android:textColor="@color/black"

  android:textSize="17sp" />

  android:id="@+id/btn_reset_signature"

  android:layout_width="0dp"

  android:layout_height="match_parent"

  android:layout_weight="1"

  android:text="重置"

  android:textColor="@color/black"

  android:textSize="17sp" />

  android:id="@+id/btn_revoke_signature"

  android:layout_width="0dp"

  android:layout_height="match_parent"

  android:layout_weight="1"

  android:text="回退"

  android:textColor="@color/black"

  android:textSize="17sp" />

  android:id="@+id/btn_end_signature"

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:text="结束签名"

  android:textColor="@color/black"

  android:textSize="17sp" />

  android:id="@+id/view_signature"

  android:layout_width="match_parent"

  android:layout_height="200dp"

  android:background="@color/white"

  app:paint_color="#0000aa"

  app:stroke_width="3" />

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="horizontal">

  android:id="@+id/btn_save_signature"

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:text="保存图片文件"

  android:textColor="@color/black"

  android:textSize="17sp" />

  android:id="@+id/iv_signature_new"

  android:layout_width="match_parent"

  android:layout_height="200dp"

  android:background="@color/white"

  android:scaleType="fitCenter" />

  SignatureActivity.java逻辑代码如下:

  package com.fukaimei.touchevent;

  import android.graphics.Bitmap;

  import android.os.Bundle;

  import android.os.Handler;

  import android.support.v7.app.AppCompatActivity;

  import android.view.View;

  import android.view.View.OnClickListener;

  import android.widget.ImageView;

  import android.widget.Toast;

  import com.fukaimei.touchevent.filedialog.dialog.FileSaveFragment;

  import com.fukaimei.touchevent.util.BitmapUtil;

  import com.fukaimei.touchevent.widget.SignatureView;

  public class SignatureActivity extends AppCompatActivity implements

  OnClickListener, FileSaveFragment.FileSaveCallbacks {

  private SignatureView view_signature;

  private ImageView iv_signature_new;

  private Bitmap mBitmap;

  @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_signature);

  view_signature = (SignatureView) findViewById(R.id.view_signature);

  iv_signature_new = (ImageView) findViewById(R.id.iv_signature_new);

  findViewById(R.id.btn_add_signature).setOnClickListener(this);

  findViewById(R.id.btn_end_signature).setOnClickListener(this);

  findViewById(R.id.btn_reset_signature).setOnClickListener(this);

  findViewById(R.id.btn_revoke_signature).setOnClickListener(this);

  findViewById(R.id.btn_save_signature).setOnClickListener(this);

  }

  @Override

  public void onClick(View v) {

  if (v.getId() == R.id.btn_save_signature) {

  if (mBitmap == null) {

  Toast.makeText(this, "请先开始然后结束签名", Toast.LENGTH_LONG).show();

  return;

  }

  FileSaveFragment.show(this, "jpg");

  } else if (v.getId() == R.id.btn_add_signature) {

  view_signature.setDrawingCacheEnabled(true);

  } else if (v.getId() == R.id.btn_reset_signature) {

  view_signature.clear();

  } else if (v.getId() == R.id.btn_revoke_signature) {

  view_signature.revoke();

  } else if (v.getId() == R.id.btn_end_signature) {

  if (view_signature.isDrawingCacheEnabled() != true) {

  Toast.makeText(this, "请先开始签名", Toast.LENGTH_LONG).show();

  } else {

  mBitmap = view_signature.getDrawingCache();

  iv_signature_new.setImageBitmap(mBitmap);

  mHandler.postDelayed(mResetCache, 100);

  }

  }

  }

  private Handler mHandler = new Handler();

  private Runnable mResetCache = new Runnable() {

  @Override

  public void run() {

  view_signature.setDrawingCacheEnabled(false);

  view_signature.setDrawingCacheEnabled(true);

  }

  };

  @Override

  public boolean onCanSave(String absolutePath, String fileName) {

  return true;

  }

  @Override

  public void onConfirmSave(String absolutePath, String fileName) {

  String path = String.format("%s/%s", absolutePath, fileName);

  BitmapUtil.saveBitmap(path, mBitmap, "jpg", 80);

  Toast.makeText(this, "成功保存图片文件:" + path, Toast.LENGTH_LONG).show();

  }

  }

  Demo程序运行效果界面截图如下:

  以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

  时间: 2019-07-15

扫描二维码推送至手机访问。

版权声明:本文由MDM苹果签名,IPA签名,苹果企业签名,苹果超级签,ios企业签名,iphoneqm.com发布,如需转载请注明出处。

转载请注明出处https://iphoneqm.com/iphoneqm/563.html

分享给朋友:

相关文章

苹果上架失败大概会有那些原因?

苹果上架失败大概会有那些原因?

  苹果上架失败是指开发者提交应用程序到苹果应用商店后,应用程序未能通过审核上架的情况。通常,苹果上架失败的原因是由于开发者未遵守苹果应用商店的规定,或者应用程序存在技术问题或版权问题。   苹...

ipa苹果企业签名作用介绍

ipa苹果企业签名作用介绍

  IPA苹果企业签名是一种使iOS设备用户可以安装未在App Store中上架的应用程序的方式。通过使用企业签名,用户可以绕过App Store的限制,安装第三方开发人员开发的应用程序。这在一些特殊...

tf签名到期之后该如何解决处理呢?

tf签名到期之后该如何解决处理呢?

  很多人都想知道为何下载了app之后没多久就会显示企业签名已过期,妨碍后续的运用,不少消费者都不清楚该如何解决。事实上企业签名过期就是掉签,今天小编就来说说tf签名到期之后该如何解决处理呢?...

苹果企业签名该如何操作?

苹果企业签名该如何操作?

  我们都知道,苹果开发人员帐户分为三类:个人开发人员帐户($99/年)、公司开发人员帐户($99/年)和企业开发人员帐户($299/年)。   这三个账户的共同点是都可以用来开发应用程序。但是...

IPA Resign Tool(IOS苹果ipa重签名工具) v2.0 绿色版

IPA Resign Tool(IOS苹果ipa重签名工具) v2.0 绿色版

  IPA Resign Tool是一款专用于修改苹果ipa文件签名的软件。这款软件可以帮助用户将ipa文件中的签名替换修改,将新的签名输入到软件中后确认即可替换文件中的原签名。签名的格式需要用户按照...

为什么海拔科技提倡IPA重签名?

为什么海拔科技提倡IPA重签名?

  今天iOS签名小编就来讲一讲,为何我们提倡IPA重签名,以及如何进行IPA重签名:   为什么ipa要重签名?   重签名可以把越狱市场上的app重新用我们自己的开发者证书进行签名,然...

现在,非常期待与您的又一次邂逅

我们努力让每一次邂逅总能超越期待

  • 高效满意
    高效满意

    专业的技术团队

  • 性能稳定
    性能稳定

    响应速度快,放心有保障

  • 用户体验
    用户体验

    响应式布局,兼容各种设备

  • 持续更新
    持续更新

    不断升级维护,更好服务用户