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;
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;
t.ContentResolver;
t.Intent;
t.IntentFilter;
t.SharedPreferences;
aphics.Bitmap;
aphics.BitmapFactory;
aphics.Color;
aphics.Paint;
aphics.drawable.BitmapDrawable;
import android.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) {
setContentView(R.layout.main);
init();
}
private void init() {
initLayout();
initButtons();
initColorViews();
initPaintView();
initPopUpWindow();
initCallBack();
initShapRadioGroups();
}
android获取真正的签名/**
* 初始化所有的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:
mPaintView.setCurrentShapType(SHAP.CIRCLE);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。