Creating Custom Views

Dependencies and prerequisites

  • Android 2.1 (API level 7) or higher

You should also read

Try it out

Download the sample

CustomView.zip

The Android framework has a large set of View classes for interacting with the user and displaying various types of data. But sometimes your app has unique needs that aren’t covered by the built-in views. This class shows you how to create your own views that are robust and reusable.

Lessons

Creating a View Class
Create a class that acts like a built-in view, with custom attributes and support from the ADT layout editor.
Custom Drawing
Make your view visually distinctive using the Android graphics system.
Making the View Interactive
Users expect a view to react smoothly and naturally to input gestures. This lesson discusses how to use gesture detection, physics, and animation to give your user interface a professional feel.
Optimizing the View
No matter how beautiful your UI is, users won't love it if it doesn't run at a consistently high frame rate. Learn how to avoid common performance problems, and how to use hardware acceleration to make your custom drawings run faster.