Android的手势的保存
                                            对手势感到好奇从网上学习了一部分。
成都创新互联公司主营惠阳网站建设的网络公司,主营网站建设方案,app软件开发,惠阳h5成都微信小程序搭建,惠阳网站营销推广欢迎惠阳等地区企业咨询
保存:
在xml中添加手势绘制即类似画板可以绘制手势的:
设置手势的一些属性:
mGov = (GestureOverlayView) findViewById(R.id.gesture); // 设置手势多笔画绘制 mGov.setGestureStrokeType(GestureOverlayView.GESTURE_STROKE_TYPE_MULTIPLE); // 设置手势绘制颜色 mGov.setGestureColor(Color.BLUE); // 设置还未形成的手势颜色为红色 mGov.setUncertainGestureColor(Color.RED); // 设置手势粗细 mGov.setGestureStrokeWidth(15); mGov.setGestureVisible(true); mGov.setFadeOffset(2000); // 绑定监听 mGov.addOnGesturePerformedListener(this);
设置手势的监听:
// 手势绘制完成后保存
		View dialogView = getLayoutInflater().inflate(R.layout.show_gesture,
				null);
		ImageView show = (ImageView) dialogView.findViewById(R.id.show);
		final EditText editext = (EditText) dialogView.findViewById(R.id.name);
		Bitmap bitmap = gesture.toBitmap(128, 128, 10, Color.BLACK);
		show.setImageBitmap(bitmap);
		new AlertDialog.Builder(MainActivity.this).setView(dialogView)
		.setPositiveButton("确定", new OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				GestureLibrary gestureLibrary = GestureLibraries
					.fromFile(Environment
						.getExternalStorageDirectory()
							+ File.separator + "yl_yl");
			gestureLibrary.addGesture(editext.getText().toString(),gesture);
				gestureLibrary.save();
				if (gestureLibrary.load()) {
					Toast.makeText(MainActivity.this, "保存成功",
							Toast.LENGTH_SHORT).show();
				} else {
					Toast.makeText(MainActivity.this, "保存失败",
							Toast.LENGTH_SHORT).show();
				}
			}
		}).setNegativeButton("取消", null).show();最后要解绑手势监听:
protected void onDestroy() {
		mGov.removeOnGesturePerformedListener(this);
		super.onDestroy();
	}手势预览xml:

这样手势就可以保存了。当然为了可以保存多个手势,手势的名字可以用时间来命名。
本文名称:Android的手势的保存
标题网址:http://www.scyingshan.cn/article/josoej.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 