2

Hello i'm trying to make an equalizer for my app but i can't figure out how to make the buttons. I don't really know how to explain myself so here is a picture that reveals more than my words: enter image description here

Do i need animations? Can you guys point me in the right direction?

Thanks in advance.

madcoderz
  • 4,423
  • 10
  • 47
  • 74
  • Seems to me that you need to create custom Views extending button of imagebutton or imageview and handle touch events. That's the first newbie thought. –  May 16 '11 at 19:12
  • @Madcoderz : I want to create an music equalizer in my app.Can you help me in that. – Arun Badole Jun 12 '13 at 17:51

3 Answers3

2

There's a nice tutorial here for creating an odometer widget. It's not at all the look you want, but many (most) of the same issues apply, including custom rendering, dealing with touch events, and wiring up a series of sub-widgets into a larger control. It's the first thing I thought of when I saw your graphic.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
1

This is simple vertical seekBar....

public class SimpleVerticalSeekBar extends SeekBar {

    public SimpleVerticalSeekBar(Context context) {
        super(context);
    }

    public SimpleVerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public SimpleVerticalSeekBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(h, w, oldh, oldw);
    }

    @Override
    protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(heightMeasureSpec, widthMeasureSpec);
        setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
    }

    protected void onDraw(Canvas c) {
        c.rotate(-90);
        c.translate(-getHeight(), 0);

        super.onDraw(c);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (!isEnabled()) {
            return false;
        }

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE:
            case MotionEvent.ACTION_UP:
                setProgress(getMax() - (int) (getMax() * event.getY() / getHeight()));
                onSizeChanged(getWidth(), getHeight(), 0, 0);
                break;

            case MotionEvent.ACTION_CANCEL:
                break;
        }
        return true;
    }
}
Ramesh Akula
  • 5,720
  • 4
  • 43
  • 67
0

I think you mean a SeekBar. It's the JSlider of Android.

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
  • @Ted I found [this older](http://stackoverflow.com/questions/631238/modifying-the-android-seekbar-widget-to-operate-vertically) topic with the same problem. – Lukas Knuth May 16 '11 at 19:50
  • Yep, the suggestions on that thread also require a custom widget. I think that's going to be a lot easier than trying to subclass SeekBar and force it to operate vertically. – Ted Hopp May 16 '11 at 19:59