Is it possible to resize the canvas in android? -


[android] have linearlayout contains 2 views, 1st imageview , th 2nd 1 have canvas on it. if mlinearlayout.addview(i); , mlinearlayout.addview(c); shows both if in reverse oder (mlinearlayout.addview(c) , mlinearlayout.addview(i)) shows canvas. wanted share screen between these 2 views. can me on this?

@override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     mlinearlayout = new linearlayout(this);      mlinearlayout.setbackgroundcolor(0xff74ac23);     imageview = new imageview(this);     view c = new drawview(this);      i.setimageresource(r.drawable.bol_groen);     i.setadjustviewbounds(true);       mlinearlayout.addview(i);     mlinearlayout.addview(c);     setcontentview(mlinearlayout);  } 

}

public class drawview extends view {

private shapedrawable mdrawable;  public drawview(context context) {     super(context);     setfocusable(true); //necessary getting touch events      mdrawable = new shapedrawable(new ovalshape());     mdrawable.getpaint().setcolor(0xff74ac23);     mdrawable.setbounds(x, y, x + width, y + height);  }  @override protected void ondraw(canvas canvas) {      canvas.drawcolor(0xffcccccc);     mdrawable.draw(canvas); 

}

give following try.

take draw statement out of ondraw call drawview or shape or ever.

//some shape//  

also dont see x , y, or height or width.

public drawview(context context) {          super(context);     setfocusable (true); //necessary getting touch events      mdrawable = new shapedrawable(new ovalshape());      mdrawable.getpaint().setcolor(0xff74ac23);       mdrawable.setbounds(x, y, x + width, y + height);        mdrawable.draw(canvas);  }   

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -