public class Mainactivity extends Activity {private ImageView iv;float StartX = 0;float Starty = 0;//Get a can be bitmapbitmap b Itmap = Bitmap.createbitmap (n, 400,bitmap.config.argb_8888);//Create a canvas canvas canvas = new canvas (BITMAP);//Create Brush Paint Paint = new Paint (), @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main); iv = (ImageView) This.findviewbyid (R.ID.IV);p Aint.setcolor (Color.Black); Paint.setstrokewidth (1);//Set Pixel Iv.setontouchlistener (new Ontouchlistener () {@Overridepublic Boolean onTouch (View V, Motionevent event) {switch (event.getaction ()) {Case MotionEvent.ACTION_DOWN:startX = Event.getx (); starty = Event.gety ( ); Break;case MotionEvent.ACTION_MOVE:float newx = Event.getx (); Float newy = Event.gety (); Canvas.drawline (StartX, Starty, Newx, newy, paint); Iv.setimagebitmap (bitmap); break;case Motionevent.action_up:break;default:break;} return true;});} @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//InflatE the menu; This adds items to the action bar if it is present.getmenuinflater (). Inflate (R.menu.main, menu); return true;}}