Android Canvas Example: Draw Sprite Sheet Animation on Canvas

Android provides several ways to implement Animations. But for different situation, we have to choose different approach. For example, if we want to create a menu dropdown animation or view slider effect, we can choose Android tweened animation. It is the basic Android animation engine which animated the view’s position, size, rotation. In this article Android View Animation Example, I have talked about this. Here is another case, if we want to create a loading icon animation or a character with regular animation, Android frame by frame animation mechanism is the best choice. You can find more information in this article Android Frame Animation Example in Flappy Bird.

However, all animation mechanisms mentioned above are still not enough to cover all scenarios. For example, how can I control the frame rate in frame by frame animation? We can start or stop the frame by frame animation, but how to pause the animation. To solve these problem, I suggest we can use sprite sheet animation. In Android, we can create a sprite sheet animations by drawing frames on Canvas within SurfaceView. In this tutorial, I will show you how to draw images on Canvas within Thread frame by frame. The frame rate is controlled by thread sleeping.

sprite sheet animation in Android
Read more

Add Admob Ads in Flash Based Android Apps

For many flash game designers and developers, Android platform is one of the best targets for them to monetize their games. However, without the native support from main advertisement platform like Admob, making money is becoming impossible with free android games. Start from Flash cs5.5, Flash Air gives us a method to use functions from outside native library. For example, we can control Android device volume or device display brightness by native Java code. As we make it as a native extension library, and we can call functions in this library from Flash.

With Flash Air native extensions, we can integrate Admob in flash games and publish them in google play and app store. In this tutorial, I will show some examples about how to write an Admob Flash Air native extensions, and how to put Admob Ads in the flash games.

Read more

10 Free Android Live Wallpapers

It is all well and good having a stationary background on our Android device. However, Android can do so much better than this. We have the ability to make that home screen come alive with animated wallpapers. They look absolutely stunning! So I decide to create my own Android live wallpaper app and share all example source code after I finish it. I may write some tutorials about how to create Android Live Wallpaper apps. Before that, I have found several free Android Live Wallpaper apps out there at the moment. I want to share with you ten of my favorite.
Read more

Android Save And Load Downloading File Locally

This is the session 3 of Android Wallpaper App tutorial. In my last android tutorial, I have shown an example to download images from internet. After downloading complete, I save the images into internal app folders, which can only access by this app. In most case, developers want to save the downloaded file in external storage, for example, sd card. Hence, I decide to start this topic here. In this android example, I will cover following topics:

  • How to save file in android internal temp folder?
  • How to save file in android internal app folder?
  • How to save file in external storage like sd-card?
  • How to load file from external storage like sd-card?

This example will base on my last android tutorial app, Android Wallpaper Manager app. In this app, I will download the wallpaper and save it locally. There are two purpose to saving images offline. First is caching the images locally so that it will load fast next time. Second is saving the wallpapers which users like so that they can use them as wallpaper later.

This Android Wallpaper App example includes four tutorials:

Read more

Android Phone Tablet Screen Size and Density

Because of varieties of screen size and density of Android phone, it is very hard for Android developers and Android UI designers to work on Android devices. To create an Android app, we try to do our best to make it compatible as many Android devices as possible. Therefore, I think it is necessary to summarize an Android device screen size and density table to help android developers and designers to check from time to time. This table doesn’t cover all the android phones and tablets.

Read more