How to use canvas in your android apps - Part 2

SDK Version: 

In the second part of this tutorial series, I will show you what you can do with canvas and paint.

If you complete the first part, your onDraw method in Panel class is similar as this:

  1.         @Override
  2.         public void onDraw(Canvas canvas) {
  4.                 Paint paint = new Paint();
  7.                 Bitmap kangoo = BitmapFactory.decodeResource(getResources(),
  8.                                 R.drawable.kangoo);
  9.                 canvas.drawColor(Color.BLACK);
  10.                 canvas.drawBitmap(kangoo, 130, 10, null);
  12.         }

We will use the the Paint type object this time. You can use it to draw lines, circles and text on your canvas. For example this two lines will draw a red circle for you.

  1. paint.setColor(Color.RED);

How to use canvas in your android apps - Part 1

SDK Version: 
If you want to use a custom layout with a canvas in your application, this tutorial may be useful to you. We will draw a kangoo at the end of this tutorial.

There is a cool article on site Custom View - HorizontalSlider, what you can use to understand the following code:

  1. [...]
  2. <com.helloandroid.canvastutorial.Panel android:id="@+id/SurfaceView01" android:layout_width="wrap_content"
  4. android:layout_height="wrap_content" android:maxHeight="40dip">
  5. </com.helloandroid.canvastutorial.Panel>
  6. [...]

This is your main.xml.

Your main class extends Activity and similar as the following code snip:

  1. public class Canvastutorial extends Activity {
  2.     /** Called when the activity is first created. */
  3.     @Override

Developing a clothing game for Android

SDK Version: 
What the hell am I doing? Developing a clothing game for Android...

Last time I was really bored, i tried to make a simple clothing game for android.

Here is the tutorial:

How to use custom designed numbers in your android widget

SDK Version: 
If you don't want to download external fonts into your application, this article will be useful to you. You can draw your own numbers for example in gimp from 0 to 9. Copy thoose numbers in to your project folder's res/drawable subfolder. Each number is a new png (for example: one.png, two.png...). Then don't forget to refresh this directory in eclipse.

In my last project I wrote an easy method, what I used to draw single numbers on a widget.

How to add external 3D fonts to your Android applications

SDK Version: 
Step 1.
First, go to, and find an eye-candy font, that you like the most. Look for „free 3d fonts”. I'm going to use this one:
After you have downloaded it, unzip if it is zipped.

Step 2.
Go to your project's location, open the „assets” folder, and create a new folder called „fonts”.
Copy and Paste your „xy.ttf” font to this new directory.

Step 3.
If you are using Eclipse, don't forget to refresh your project's directory tree, make sure your SDK can see your font file.

  1. /* Setting up fonts */
  2. Typeface fontFace = Typeface.createFromAsset(getAssets(), "fonts/xtrusion.ttf");
  3. Typeface fontFace2 = Typeface.createFromAsset(getAssets(), "fonts/other.ttf");
  4. TextView someText = (TextView)findViewById(;

Syndicate content