Search code examples
androidcomponentsseekbar

How to create custom graphical component


I would like to create custom component similar to this picture.

sample control preview

So I could set fan speed (from 0 to 4) and and timer (from 0 to 9). If I set fan speed greater than zero it would be nice to rotate the fan image.

What is the best approach to create such component?


Solution

  • You have to create your custom view which handlers your taps and gestures and draws anything you want. Just a simple example.

    public class MyView extends View {
    //
    @Override
        protected void onDraw(Canvas canvas) {
    
            super.onDraw(canvas);
    
    //setup your output drawables here
    }
    

    Huge example:

    https://developer.android.com/training/custom-views/create-view.html