爲孩子創建應用程序是一項艱鉅的任務,我被賦予創建連接點應用程序的任務。 例如連接圖像點的點
https://play.google.com/store/apps/details?id=zok.android.dots
我做的onTouchEvent的一些教程。
我知道如何在屏幕上Draw in Canvas by finger, Android
我得到的點使用該Android: How do I get the x y coordinates within an image/ImageView?例如
座標,但我真的不知道該如何實現這個目標漆料。 我真的很感激這個解決方案!謝謝!
輸入圖像是http://imgur.com/Z24yQUx,t6nL71r
編輯
@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);
}
我給你說什麼,用點的座標,但由於用戶可能無法觸摸的ArrayList 設置這些座標,即使我們嘗試添加或觸摸的座標減去價值實現這一目標的方法是困難的(假設20) –
看看你將點按數字順序排列,然後可以按照順序檢查它,如果順序錯誤,則標記線條顏色不同(例如,如果正確的線條是綠色的,錯誤的線條是紅色的), 如果您不沒有點的順序,然後只是檢查所有的點座標時,用戶舉起他的手指 – Ari
謝謝你:@Ari imgur.com/Z24yQUx,t6nL71r看到這個形象猜測,如果命令是錯誤的,因爲我使用MotionEvent.ACTION_MOVE:path.lineTo(pointX,pointY); public float [] [] co_ordinates = {{18,429},{68,220},{169,26},{245,220},{279,426}};這是座標,但是這個邏輯將在不同的屏幕尺寸設備上失敗。 –