android - Draw random bitmap in the onDraw method -


firstly adding cards list that:

    private void initcards() {     (int = 0; < 20; i++) {       bitmap tempbitmap = bitmapfactory.decoderesource(mycontext.getresources(),r.drawable.ic_launcher);     scaledcardw = (int) (screenw/10);      scaledcardh = (int) (scaledcardw*1.28);     bitmap scaledbitmap = bitmap.createscaledbitmap(tempbitmap,scaledcardw, scaledcardh, false);             deck.add(scaledbitmap);       } 

but when came on draw method,my program transforming thing animation. ondraw method here:

    protected void ondraw(canvas canvas) {     // todo auto-generated method stub     super.ondraw(canvas);      int left=newinteger.nextint(screenw);     int right=newinteger.nextint(screenh);      for(int i=0 ; i<k ;i++){         canvas.drawbitmap(deck.get(i), left, right, null);     }   } 

these bitmaps must have random location , if change k our main activity different numbers of bitmaps must drawen.because of that,ı cannot remove invalite() function.

can me?unfortunately,another topics problem not providing request.

your bitmaps keep moving because randomizing position every time draw. try moving these lines:

left = newinteger.nextint(screenw); right = newinteger.nextint(screenh); 

into same function changes value of k.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -