android 手写签批_android 画板(可做手写签名)示例源码

【实例简介】【实例截图】【核心代码】package com.firstpeople.paintpad.activity;import java.io.File;import java.util.ArrayList;import java.util.List;import com.firstpeople.paintpad.interfaces.EditTextDialogListener;impor...
摘要由CSDN通过智能技术生成

【实例简介】

【实例截图】

【核心代码】

package com.firstpeople.paintpad.activity;

import java.io.File;

import java.util.ArrayList;

import java.util.List;

import com.firstpeople.paintpad.interfaces.EditTextDialogListener;

import com.firstpeople.paintpad.interfaces.OnClickOkListener;

import com.firstpeople.paintpad.interfaces.PaintViewCallBack;

import com.firstpeople.paintpad.utils.BitMapUtils;

import com.firstpeople.paintpad.utils.ImageButtonTools;

import com.firstpeople.paintpad.utils.PaintConstants.ERASER_SIZE;

import com.firstpeople.paintpad.utils.PaintConstants.PEN_SIZE;

import com.firstpeople.paintpad.utils.PaintConstants.SHAP;

import com.firstpeople.paintpad.view.ColorPickerDialog;

import com.firstpeople.paintpad.view.ColorPickerDialog.OnColorChangedListener;

import com.firstpeople.paintpad.view.ColorView;

import com.firstpeople.paintpad.view.OkCancleDialog;

import com.firstpeople.paintpad.view.OkDialog;

import com.firstpeople.paintpad.view.PaintView;

import com.firstpeople.paintpad.activity.R;

import com.firstpeople.paintpad.view.SaveDialog;

import android.app.Activity;

import android.content.ContentResolver;

import android.content.Intent;

import android.content.IntentFilter;

import android.content.SharedPreferences;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.Color;

import android.graphics.Paint;

import android.graphics.drawable.BitmapDrawable;

import android.net.Uri;

import android.os.Bundle;

import android.os.Environment;

import android.util.Log;

import android.view.Gravity;

import android.view.KeyEvent;

import android.view.LayoutInflater;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.CompoundButton;

import android.widget.CompoundButton.OnCheckedChangeListener;

import android.widget.Button;

import android.widget.ImageButton;

import android.widget.LinearLayout;

import android.widget.RadioButton;

import android.widget.LinearLayout.LayoutParams;

import android.widget.PopupWindow;

import android.widget.RadioGroup;

import static com.firstpeople.paintpad.utils.PaintConstants.*;

/**

* Main Activity实现了主场景的Activity主要负责PaintView与各组件的协调

*

* @author tf

*

*/

public class Main extends Activity implements OnClickListener {

// PaintView

private PaintView mPaintView = null;

// button 界面上的各个按钮

private ImageButton saveButton = null;

private ImageButton loadButton = null;

private ImageButton clearButton = null;

private ImageButton eraserButton = null;

private ImageButton colorSelectButton = null;

private ImageButton penSizeButton = null;

private ImageButton undoButton = null;

private ImageButton redoButton = null;

private ImageButton toButtonLayoutButton = null;

private ImageButton toColorLayoutButton = null;

private ImageButton toolButton = null;

// 点击工具按钮弹出浮动菜单上的按钮

private Button backGroundColorButton = null;

private Button plainPaintButton = null;

private Button blurPaintButton = null;

private Button embossButton = null;

// 点击Menu弹出的功能菜单

private ImageButton exitButton = null;

private ImageButton aboutButton = null;

private ImageButton helpButton = null;

// 两个PopWindow

private PopupWindow mPopupWindow = null;

private PopupWindow toolsPopupWindow = null;

// 一共8个ColorView

private ColorView colorView1 = null;

private ColorView colorView2 = null;

private ColorView colorView3 = null;

private ColorView colorView4 = null;

private ColorView colorView5 = null;

private ColorView colorView6 = null;

private ColorView colorView7 = null;

private ColorView colorView8 = null;

// 通过控制Layout来控制某些变化

private LinearLayout colorLayout = null;

private LinearLayout buttonLayout = null;

private LinearLayout paintViewLayout = null;

private LinearLayout eraserSizeLayout = null;

private LinearLayout penSizeLayout = null;

private LinearLayout shapLayout = null;

private LinearLayout shapLayoutf = null;

// 一些RadioGroup和重要的(也就是默认的)RadioButton

private RadioGroup colorRadioGroup = null;

private RadioGroup eraserSizeRadioGroup = null;

private RadioButton eraserSizeRadio01 = null;

private RadioGroup penSizeRadioGroup = null;

private RadioButton penSizeRadio1 = null;

private RadioGroup shapRadioGroup = null;

private RadioGroup shapRadioGroupf = null;

private RadioButton curvRadioButton = null;

// 用于两个SizeRadioGroup的一些操作

private boolean clearCheckf = false;

private boolean clearCheck = false;

private List mColorViewList = null;

// 使用PenType临时存储选择的变量,当创建时再传给PaintView

private int mPenType = PEN_TYPE.PLAIN_PEN;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

init();

}

private void init() {

initLayout();

initButtons();

initColorViews();

initPaintView();

initPopUpWindow();

initCallBack();

initShapRadioGroups();

}

/**

* 初始化所有的RadioGroup

*/

private void initShapRadioGroups() {

shapRadioGroup = (RadioGroup) findViewById(R.id.shapRadioGroup);

curvRadioButton = (RadioButton) findViewById(R.id.RadioButtonShapCurv);

shapRadioGroupf = (RadioGroup) findViewById(R.id.shapRadioGroupf);

initEraseSizeGroup();

initPenSizeGroup();

initShapRadioGroup();

initShapRadioGroupf();

}

private void initShapRadioGroupf() {

shapRadioGroupf

.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

@Override

public void onCheckedChanged(RadioGroup group, int checkedId) {

// 如果当前没有选中

if (checkedId == -1) {

return;

}

if (clearCheck == false) {

clearCheckf = true;

shapRadioGroup.clearCheck();

}

mPaintView.setPenStyle(Paint.Style.FILL);

switch (checkedId) {

case R.id.RadioButtonShapLine:

mPaintView.setCurrentShapType(SHAP.LINE);

mPaintView.setPenStyle(Paint.Style.STROKE);

break;

case R.id.RadioButtonShapRectf:

mPaintView.setCurrentShapType(SHAP.RECT);

break;

case R.id.RadioButtonShapCirclef:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值