Android实现签名涂鸦手写板
作者:BoomLei 发布时间:2022-07-27 04:10:14
标签:Android,签名,手写板
本文实例为大家分享了Android实现签名涂鸦手写板的具体代码,供大家参考,具体内容如下
布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fl_signature"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:background="@drawable/singature_bg"
android:gravity="top">
</FrameLayout>
<ImageView
android:id="@+id/iv_signature"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:background="@drawable/signature_shape"
android:gravity="top"
android:visibility="gone"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp">
<TextView
android:id="@+id/tv_revert_signature"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_marginRight="140dp"
android:background="@drawable/btn_order_details_pay_bg"
android:gravity="center"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:text="重签"
android:textColor="@color/code_number_bg"
android:textSize="@dimen/text_title_word" />
<TextView
android:id="@+id/tv_signature_save"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="@drawable/bt_bg"
android:gravity="center"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:text="保存"
android:textColor="@color/white"
android:textSize="@dimen/text_title_word" />
</RelativeLayout>
</LinearLayout>
//开始签名
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();
}
来源:https://blog.csdn.net/BoomLei/article/details/77368473


猜你喜欢
- 前言:上篇C#进阶系列——WebApi接口传参不再困惑:传参详解介绍了WebApi参数的传递,这篇来看看WebApi里面异常的处理。关于异常
- 前言在Java 8之前,默认情况下,接口中的所有方法都是公共的和抽象的。但是这一限制在Java 8中被打破了,Java 8允许开发人员在接口
- Spring多数据源实现的方式大概有2中,一种是新建多个MapperScan扫描不同包,另外一种则是通过继承AbstractRoutingD
- 由于需要访问MongoDB,但是本地开发环境不能直接连接MongoDB,需要通过SecureCRT使用127.0.0.2本地IP代理。但是程
- 楼主大菜鸟一只,第一次写技术博客,如果有概念错误或代码不规范的地方,还请各位多多批评指正。话不多说,来看题:前一阵子开发了一个用户控件,里面
- 本文实例讲述了Java网络编程实现的简单端口扫描器。分享给大家供大家参考,具体如下:在计算机网络的学习中,不由得觉得这门课的零碎知识点异常之
- RequestHeaders添加自定义参数在开发过程中有的时候,参数需要绑定到requestHeaders中,而并不是在body中进行传输。
- Android 调用发送短信的方 * 能:调用发送短信功能 1 、 权限 <uses-permission android:name=&
- 本文实例为大家分享了java实现在线聊天系统的具体代码,供大家参考,具体内容如下本博客是博主在观看相关视频后写下的代码,希望能够帮助大家掌握
- 要使用Dictionary集合,需要导入C#泛型命名空间 System.Collections.Generic(程序集:mscor
- 引言综合应用Java的GUI编程和网络编程,实现一个能够支持多组用户同时使用的聊天室软件。该聊天室具有比较友好的GUI界面,并使用C/S模式
- Java提供一种机制叫做序列化,通过有序的格式或者字节序列持久化java对象,其中包含对象的数据,还有对象的类型,和保存在对象中
- 汉诺塔的规则是:一共三根柱子,一根柱子从上到
- 介绍  日常的业务开发,我们会重复编写一些代码:日期和字符串相互转换、发送Http请求调用接口、拷贝对象
- 本文实例讲述了C#实现的算24点游戏算法。分享给大家供大家参考。具体如下:using System;using System.Collect
- 使用List.contains(Object object)方法判断ArrayList是否包含一个元素对象(针对于对象的属性值相同,但对象地
- 关于死信队列在大多数的MQ中间件中,都有死信队列的概念。死信队列同其他的队列一样都是普通的队列。在RabbitMQ中并没有特定的“死信队列”
- 在面向对象编程中,SOLID 是五个设计原则的首字母缩写,旨在使软件设计更易于理解、灵活和可维护。这些原则是由美国软件工程师和讲师
- 在开始本文前先考虑以下一个问题在不使用任何带有自动补全功能IDE的情况下,如何获取一个数组的长度?以及,如何获取一个字符串的长度?这个问题我
- C#Windows server2016服务器搭建NFS共享文件夹与C#上传图片到共享文件夹nfs共享文件夹实现步骤基于:Windows s