Tuesday, August 31, 2010

Working With Canvas in Android

 Some Examples to work with Canvas


Drawing a Round Rectangle 


                Path path = new Path();
RectF rect=new RectF(60,  05, 300, 25);
// rectangle with 10 px Radius
path.addRoundRect(rect, 10, 10, Direction.CCW);
canvas.drawPath(path, p);

Drawing a text 

                              Paint p = new Paint();
             p.setColor(Color.WHITE);

                             p.setTextSize(16);
            Typeface tf=Typeface.SANS_SERIF ;
            p.setTypeface(tf);
            p.setFakeBoldText(true);


                            canvas.drawText("Map ", 380, 20,  p);

Drawing a Bitmap Image

        Bitmap mapbmp=BitmapFactory.decodeResource(getResources(), R.drawable.mapicon);
canvas.drawBitmap(mapbmp, 360, 05, p); 




2 comments:

  1. I simply couldn't go away your web site before
    suggesting that I actually loved the standard information an individual supply in your visitors?

    Is going to be back ceaselessly to investigate cross-check new posts

    my site - new york web design company

    ReplyDelete
  2. Hi to all, how is the whole thing, I think every one is getting more
    from this site, and your views are pleasant for new people.


    Also visit my web site - spaghetti przepis

    ReplyDelete

Android Developers Blog

Ram's shared items