连接一个ImageView的的点 [英] Connect the dots of an imageview
问题描述
这是一个艰巨的任务,以创建为孩子们的应用程序,并能给我建立一个连接点的应用程序的任务。 例如
https://play.google.com/store/应用程序/详细信息?ID = zok.android.dots
我做的onTouchEvent的一些教程。
我知道怎么画在屏幕上画在画布通过手指的Android
我得到的点坐标使用该<一href="http://stackoverflow.com/questions/8909835/android-how-do-i-get-the-x-y-coordinates-within-an-image-imageview">Android:我如何获得一个图像/的ImageView内的XY坐标?例如
但我真的不知道该如何实现这个目标。 我真的AP preciate解决这个!谢谢!
输入图像是 http://imgur.com/Z24yQUx,t6nL71r
修改
@覆盖
保护无效的OnDraw(帆布油画){
// BackgroundBitmap指令是,我想在后台显示的图像
如果(DISPLAY_ALPHABET == 0)
{
canvas.drawBitmap(BackgroundBitmap指令,0F,0F,NULL);
DISPLAY_ALPHABET = 1;
}
显示(画布);
}
公共无效展(油画画布)
{
涂料粉刷=新的油漆();
INT CNT = 1;
canvas.drawPaint(油漆);
//数字彩
paint.setColor(Color.BLUE);
paint.setTextSize(16);
canvas.drawColor(背景);
** canvas.drawBitmap(mBitmap,0,0,NULL); **
canvas.drawPath(的mpath,mPaint);
mPaint.setColor(Color.BLACK);
在画布上绘制//点
对于(点点:M点){
canvas.drawPoint(point.x,point.y,mPaint);
canvas.drawText(+ CNT ++ point.x-7,point.y-7,漆);
}
mPaint.setColor(Color.RED);
}
我没有太多的想法有关这一点,但还是觉得值得思考
您可以保存在一个数组列表或向量的下一个点坐标。 当您使用绘图画布上线,检查是否运动事件x和y坐标匹配到向量中的下一个点。
在一个坐标感动搜索下一个在矢量
您可以使用一个计数器来增加向量的位置,一旦触及点递增计数器。
编辑:看看我的演示应用程序在此链接,然后检查你可能需要
It is a difficult task to create an app for kids and i am given a task of creating an connect the dots app. example
https://play.google.com/store/apps/details?id=zok.android.dots
i have done some tutorials of onTouchEvent.
i know how to paint on screen Draw in Canvas by finger android
i am getting the dot coordinates using this Android: How do I get the x y coordinates within an image / ImageView? example
but I really don't know how to achieve this target. I'd really appreciate a solution to this! Thanks!
input image is http://imgur.com/Z24yQUx,t6nL71r
EDIT
@Override
protected void onDraw(Canvas canvas) {
//backgroundBitmap is the image i want to show in background
if(DISPLAY_ALPHABET==0)
{
canvas.drawBitmap(backgroundBitmap, 0f, 0f, null);
DISPLAY_ALPHABET=1;
}
show(canvas);
}
public void show(Canvas canvas)
{
Paint paint = new Paint();
int cnt=1;
canvas.drawPaint(paint);
//color of numbers
paint.setColor(Color.BLUE);
paint.setTextSize(16);
canvas.drawColor(BACKGROUND);
** canvas.drawBitmap(mBitmap, 0, 0, null);**
canvas.drawPath(mPath, mPaint);
mPaint.setColor(Color.BLACK);
//Drawing points on canvas
for (Point point : mPoints) {
canvas.drawPoint(point.x, point.y, mPaint);
canvas.drawText(""+cnt++, point.x-7, point.y-7, paint);
}
mPaint.setColor(Color.RED);
}
I don't have much idea about this but still felt like worth thinking
You can save the next dot coordinates in a arraylist or a vector. when you are drawing the line using canvas, check whether the Motion-Event x and y coordinates matches to that of the next point in the vector.
Once a coordinate is touched search for the next one in the vector
You can use a counter to increase the vector position, once the dot touched increment the counter.
EDIT: Check out my Demo App in this Link and check what you might need.
这篇关于连接一个ImageView的的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!