Use this
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class Draw extends Activity {
DrawView drawView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set full screen view
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
drawView = new DrawView(this);
setContentView(drawView);
drawView.requestFocus();
}
}
package guru.com.aaa;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
public class DrawView extends View implements OnTouchListener {
private static final String TAG = "DrawView";
List<Point> points = new ArrayList<Point>();
Paint paint = new Paint();
public DrawView(Context context) {
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
this.setOnTouchListener(this);
paint.setColor(Color.WHITE);
paint.setAntiAlias(true);
}
@Override
public void onDraw(Canvas canvas) {
for (Point point : points) {
canvas.drawCircle(point.x, point.y, 25, paint);
// Log.d(TAG, "Painting: "+point);
}
}
public boolean onTouch(View view, MotionEvent event) {
// if(event.getAction() != MotionEvent.ACTION_DOWN)
// return super.onTouchEvent(event);
Point point = new Point();
point.x = event.getX();
point.y = event.getY();
points.add(point);
invalidate();
Log.d(TAG, "point: " + point);
return true;
}
}
class Point {
float x, y;
@Override
public String toString() {
return x + ", " + y;
}
}
On Thu, Jun 14, 2012 at 12:27 PM, ajaykumar kanchak <
[email protected]> wrote:
> to draw the circle on touch with the finger use this code this is with the
> gesture listener
>
>
> public class GesturesActivity extends Activity implements
> OnGesturePerformedListener {
> private GestureLibrary mLibrary;
>
>
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
>
> mLibrary = GestureLibraries.fromRawResource(this, R.raw.spells);
> if (!mLibrary.load()) {
> finish();
> }
>
> GestureOverlayView gestures = (GestureOverlayView)
> findViewById(R.id.gestures);
> gestures.addOnGesturePerformedListener(this);
> }
>
> public void onGesturePerformed(GestureOverlayView overlay, Gesture
> gesture) {
> ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
>
> // We want at least one prediction
> if (predictions.size() > 0) {
> Prediction prediction = predictions.get(0);
> // We want at least some confidence in the result
> if (prediction.score > 1.0) {
> // Show the spell
> Toast.makeText(this, prediction.name,
> Toast.LENGTH_SHORT).show();
>
> }
> }
> }
> }
>
>
>
>
> On Thu, Jun 14, 2012 at 12:12 PM, Amey Bapat <[email protected]>wrote:
>
>> public class Home extends Activity {
>> /** Called when the activity is first created. */
>> @Override
>> public void onCreate(Bundle savedInstanceState) {
>> super.onCreate(savedInstanceState);
>> setContentView(new MySurface(this));
>> }
>> }
>>
>>
>>
>> heres da code fr MySurFace
>>
>>
>> public class MySurface extends ImageView {
>>
>> float x, y;
>> Path path = new Path();
>> public MySurface(Context context) {
>> super(context);
>> this.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT,
>> LayoutParams.FILL_PARENT));
>> this.setOnTouchListener( new OnTouchListener() {
>> public boolean onTouch(View v, MotionEvent event) {
>> x = event.getX();
>> y = event.getY();
>> invalidate();
>> return false;
>> }
>> });
>> }
>> @Override
>> public boolean onTouchEvent(MotionEvent event) {
>> x = event.getX();
>> y = event.getY();
>> invalidate();
>>
>> return super.onTouchEvent(event);
>> }
>> @Override
>> protected void onDraw(Canvas canvas) {
>> // TODO Auto-generated method stub
>> super.onDraw(canvas);
>> Paint paint = new Paint();
>> paint.setColor(Color.RED);
>> //canvas.drawLine(x, y, x+20, y+20, paint);
>> path.moveTo(x, y);
>> //path.lineTo(x, y);
>> canvas.drawPath(path, paint);
>> }
>>
>> }
>>
>>
>> just edit some methods fr drawing...
>> check out canvas methods for drwaing stuff..
>> all da best
>>
>> On Thu, Jun 14, 2012 at 11:51 AM, Sadhna Upadhyay <
>> [email protected]> wrote:
>>
>>>
>>> Hi everyone,
>>> I am making an app in which i have to to draw circle with the help of
>>> finger(on touch listener) in android ,
>>> can anyone help me
>>>
>>>
>>>
>>>
>>>
>>> Thanks and Regard
>>> sadhana
>>>
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>>
>>
>>
>>
>> --
>> live and let LIVE!!!
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>
>
> --
> Thanks & Regards
> K. Ajay Kumar
> 9700188853
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en