Android画板控件,可以写字,签名,画画并生成图片

1效果图

 

实现步骤

1、添加画板控件module

画板控件module下载:https://download.csdn.net/download/meixi_android/10774781

2、xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutandroid:id="@+id/content_main"xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:background="@color/white"app:layout_behavior="@string/appbar_scrolling_view_behavior"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="8dp"android:layout_marginTop="8dp"android:background="@color/blistlic"></LinearLayout><Buttonandroid:id="@+id/btn_reset"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="40dp"android:layout_margin="10dp"android:text="重置"android:textSize="16dp"android:textColor="#fff"android:background="@drawable/selebuttonbg"/><Buttonandroid:id="@+id/btn_bitmap"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="40dp"android:layout_margin="10dp"android:text="确认"android:textSize="16dp"android:background="@drawable/selebuttonbg"android:textColor="#fff" /><com.unco.library.PainterViewandroid:id="@+id/painter"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/defaulcolor"/>
</LinearLayout>

3、activity代码详情

/*** 作者:created by meixi* 邮箱:13164716840@163.com* 日期:2018/11/9 13*/
public class QianmingActivity extends MainBaseFragmentActiciry {@BindView(R.id.backliqianming)LinearLayout backliqianming;@BindView(R.id.btn_reset)Button btn_reset;@BindView(R.id.btn_bitmap)Button btn_bitmap;@BindView(R.id.painter)PainterView painter;private String ss;@Overrideprotected void onCreate(Bundle arg0) {super.onCreate(arg0);setContentView(R.layout.qianmingla);ButterKnife.bind(this);ss = getIntent().getStringExtra("type");painter.clear();}@OnClick({R.id.backliqianming,R.id.btn_reset,R.id.btn_bitmap})public void onClick(View view) {switch (view.getId()) {case R.id.backliqianming:onBackPressed();break;case R.id.btn_reset:painter.clear();break;case R.id.btn_bitmap:Bitmap bitmap = painter.creatBitmap();if (ss.equals("ww")){BObServernotice.getInstance().notifyObserver(1,bitmap);}else if (ss.equals("jj")){BObServernotice.getInstance().notifyObserver(2,bitmap);}onBackPressed();break;}}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/414994.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【网络流24题】餐巾计划问题(最小费用最大流)

【网络流24题】餐巾计划问题&#xff08;最小费用最大流&#xff09; 题面 COGS 洛谷上的数据范围更大&#xff0c;而且要开longlong 题解 餐巾的来源分为两种&#xff1a; ①新买的 ②旧的拿去洗 所以&#xff0c;两种情况分别建图 先考虑第一种 因为新买餐巾没有任何限制&…

js正则表达式匹配span标签

1、js正则表达式匹配span标签 const spans htmlStr.match(/<span (.*?)>(.*?)<\/span>/g)2、js正则表达式–获取标签内的文本 function fn(str) {return str.match(/<span[^>]*>([\s\S]*?)<\/span>/)[1] }

工作209:整理订单的重置逻辑

1点击新增 2找到子组件下面的混入 3找到混入 4这一块或许就是重置逻辑

phaser设置图片资源大小

核心代码如下&#xff1a; // 加载图片资源 this.load.image(pic6, /images/phaser/img/pic6.png) const pic this.add.image(1505, 630, pic6) pic.displayWidth 100 pic.displayHeight 100

位域操作

看runtime源码时&#xff0c;看到如下声明变量的&#xff0c;变量后分号前加冒号和数字": 数字"即为位域操作。 uintptr_t indexed : 1; 1个字节包含8位&#xff0c;有些变量保存的数据不需要占用这么长的空间&#xff08;比如bool类型&#xff0c;只有两个…

工作211:新的封装组件 秒呀

<!-- 可以动态新增的 tag 列表 --> <template><div><el-tagv-for"(tag, index) in dynamicTags":key"index":closable"true":disable-transitions"false"close"handleClose(tag)">{{ tag }}</el…

HTTP协议简介,数据安全 如何保证http传输安全性,http与https区别

目前大多数网站和app的接口都是采用http协议&#xff0c;但是http协议很容易就通过抓包工具监听到内容&#xff0c;甚至可以篡改内容&#xff0c;为了保证数据不被别人看到和修改&#xff0c;可以通过以下几个方面避免。 重要的数据&#xff0c;要加密&#xff0c;比如用户名密…

mongoose只更新数组中某一项的字段

只是需要一个特殊符号$代表匹配某一项 数据库设计如下&#xff1a; 核心代码如下&#xff1a; // 回答试题public async userPaperAnswer(request: IRequest, _h: IResponse) {const { user_paper_id, question_id, option_user } request.payload;const updOne await Use…

Koa2+Mysql搭建简易博客

http://blog.csdn.net/wclimb/article/details/77890793 转载于:https://www.cnblogs.com/SharkChilli/p/8177753.html

工作213:不能改变父组件值

父组件通过props传值给子组件&#xff0c;如何避免子组件改变props的属性值报错问题 报错Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop’s v…

uniapp移动H5在花生壳Invalid Host header

解决方案&#xff0c;在manifest.json中配置 "h5" : {"title" : "","domain" : "","devServer" : {"disableHostCheck" : true} }

Android 下拉式抽屉折叠动画

自定义listview工具类1、 public class ViewMeasureUtils {/*** 根据父 View 规则和子 View 的 LayoutParams&#xff0c;计算子类的宽度(width)测量规则** param view*/public static int getChildWidthMeasureSpec(View view, int parentWidthMeasureSpec) {// 获取父 View …

18.抽象模板方法———获取程序运行的时间

需求&#xff1a;获取一段程序运行的时间。原理&#xff1a;   获取程序开始和结束的额时间并相见即可  获取时间&#xff1a;System.currentTimeMillis(); 当代码完成优化后&#xff0c;就可以解决这类问题。这种方式&#xff0c;叫模板方法设计模式。 什么是模板方法呢&a…

js随机从数组中取出几个元素

这篇文章为转载&#xff0c;我的需求是从题库中&#xff0c;随机抽几道题&#xff0c;作为新试卷。代码如下&#xff1a; var items [1,2,4,5,6,7,8,9,10];1.从数组items中随机取出一个元素 var item items[Math.floor(Math.random()*items.length)];2.从前面的一篇随机数组…

工作214:结构 vue操作一个很有意思的报错 [Vue warn]: You may have an infinite update loop in a component

结构 vue操作一个很有意思的报错 [Vue warn]: You may have an infinite update loop in a component render function. 代码&#xff1a; <template><span class"show-filters" &#xff1a;class"show !show">{{ show ? 隐藏过滤器 ↑ …

Android 实现选中与非选中样式效果

drawable文件 <?xml version"1.0" encoding"utf-8"?> <selector xmlns:android"http://schemas.android.com/apk/res/android"><item android:drawable"drawable/log_button_bgok" android:state_focused"true&…

beta冲刺总结

团队成员及分工 姓名学号分工陈家权031502107前端&#xff08;消息模块&#xff09;赖晓连031502118前端&#xff08;问答模块&#xff09;雷晶031502119服务器林巧娜031502125前端&#xff08;首页模块&#xff09;一、项目预期计划及现实进展 项目预期计划现实进展解决页面异…

cesium polygon 悬浮在半空中

效果如下&#xff1a; 代码&#xff1a; let arr [[120.87140893447473, 31.877030830389447, 128.64],[120.87140872335587, 31.876963534304792, 128.64],[120.87202301763111, 31.87696299560446, 128.63],[120.87202432001283, 31.877030271988385, 128.63]]arr [].con…

工作215:点击按钮报错

获取值有点问题 点击同一按钮获取值有问题