产品定位
用于会议迎宾,可以随便编辑内容,签到,扫码上传服务器功能
编辑部分代码
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!---->
<link rel="stylesheet" type="text/css" href="normalize.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="font.css">
<!---->
</head>
<body>
<!--style="font-size:50px"-->
<div id="editor" contentEditable="true" style="face:song-ti; font-size:50px; color:#ffffff;">
</div>
<script type="text/javascript" src="rich_editor.js"></script>
<script type="text/javascript">
function getWidth(){
var div = document.getElementById('editor');
<!-- return div.offsetWidth;-->
return div.scrollWidth;
}
</script>
</body>
</html>
通过富文本来显示字体 可以拖拽 改变字体大小 改变字体 全选
public void setText(String text) {
exec("javascript:RE.setText('" + text + "');");
}
public void setFontName(String fontName) {
exec("javascript:RE.setFontName('" + fontName + "');");
}
public void setBaseFontSize(String px){
LogUtils.d("RichEditor","setBaseFontSize,px:" + px);
exec("javascript:RE.setBaseFontSize('" + px + "');");
}
签名部分代码
@Override
public boolean onTouchEvent(MotionEvent event) {
int size = event.getPointerCount();
int pointerId = -1;
touchSize = event.getTouchMajor();
if (activity != null){
activity.mThresholdText.setText(touchSize + "");
}
if(cacheMode == eraser){
eraserMatrix.reset();
eraserMatrix.postTranslate(event.getX() - eraserBitmap.getWidth() / 2, event.getY() - eraserBitmap.getHeight() / 2);
}else if(cacheMode == normal){
if(touchSize >= JUDGE_AREA){
cacheMode = mix_eraser;
eraserMatrix.reset();
eraserMatrix.postTranslate(event.getX() - eraserBitmap.getWidth() / 2, event.getY() - eraserBitmap.getHeight() / 2);
}
}else if(cacheMode == mix_eraser){
eraserMatrix.reset();
eraserMatrix.postTranslate(event.getX() - eraserBitmap.getWidth() / 2, event.getY() - eraserBitmap.getHeight() / 2);
}
Log.d("Signature","onTouchEvent,point count:" + size);
//Log.d("Signature","onTouchEvent,touchSize:" + touchSize);
Log.d("Signature","onTouchEvent,action:" + event.getActionMasked() + ",actionIndex:" + event.getActionIndex());
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN: //0
pointerId = event.getPointerId(event.getActionIndex());
if (penCon != null) {
penCon.setVisibility(GONE);
}
if(cacheMode == eraser){
isEraserVisible = true;
addPath(pointerId, event.getX(event.getActionIndex()), event.getY(event.getActionIndex()),cacheMode);
}else{
addPath(pointerId, event.getX(event.getActionIndex()), event.getY(event.getActionIndex()),cacheMode);
}
break;
case MotionEvent.ACTION_POINTER_DOWN: //5
pointerId = event.getPointerId(event.getActionIndex());
if (penCon != null) {
penCon.setVisibility(GONE);
}
if(cacheMode != eraser){
addPath(pointerId, event.getX(event.getActionIndex()), event.getY(event.getActionIndex()),cacheMode);
}
break;
case MotionEvent.ACTION_POINTER_UP: //6
case MotionEvent.ACTION_CANCEL:
pointerId = event.getPointerId(event.getActionIndex());
if(cacheMode == eraser){
pathMap.remove(pointerId);
}else{
drawPenLine(pointerId);
pathMap.remove(pointerId);
}
break;
case MotionEvent.ACTION_UP: //1
pointerId = event.getPointerId(event.getActionIndex());
if(cacheMode == mix_eraser){
cacheMode = normal;
pathMap.remove(pointerId);
}else if(cacheMode == eraser){
isEraserVisible = false;
pathMap.remove(pointerId);
}else{
drawPenLine(pointerId);
pathMap.remove(pointerId);
}
break;
case MotionEvent.ACTION_MOVE: //2
if (onSigningListener != null) {
onSigningListener.onSigning(true);
}
if(cacheMode == eraser){
drawPenPath(event.getPointerId(0),event.getX(0),event.getY(0));
}else{
for (int i = 0; i < size; i++) {
drawPenPath(event.getPointerId(i),event.getX(i),event.getY(i));
}
}
break;
}
invalidate();
return true;
}
private void drawPenPath(int pointerId,float x,float y){
Style style = pathMap.get(pointerId);
if(style == null){
if(cacheMode == eraser){
addPath(pointerId,x,y,cacheMode);
}
return;
}
style.setMode(cacheMode);
Path path = style.getPath();
PointF pointF = style.getPointF();
mPaint.setColor(style.getColor());
mPaint.setStrokeWidth(style.getStrokeWidth());
float dx = Math.abs(x - pointF.x);
float dy = Math.abs(y - pointF.y);
double s = Math.sqrt(Math.pow(x - pointF.x, 2) + Math.pow(y - pointF.y, 2));//计算两点之间的距离
if (path != null) {
//if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE)
if (s < TOUCH_TOLERANCE) {//解决在Android5.0的系统下 反复在一点移动会出现毛刺的情况
//path.lineTo(x, y);
}else{
//path1.quadTo(pointF.x,pointF.y,x,y);
path.quadTo(pointF.x, pointF.y, (x + pointF.x) / 2, (y + pointF.y) / 2);
pointF.x = x;
pointF.y = y;
//test start+++
if (style.getMode() == eraser || style.getMode() == mix_eraser)
mCanvas.drawPath(path, mEraserPaint);
/*else
mCanvas.drawPath(path, mPaint);*/
//test end---
}
}
}
同样是书写 不过没有白板那么高要求 那么多功能所以是用一种很普遍的view书写
效果图
网友评论