Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a vertical SeekBar in Android?

Can a SeekBar be vertical? I am not very good at UI design, so how can I make the SeekBar more beautiful, please give me some templates and examples.

like image 212
Chris Avatar asked Jul 26 '10 09:07

Chris


People also ask

How do I change the SeekBar thumb on Android?

Just add android:thumbTint="@color/yourColor" in your seekbar.

What is a SeekBar?

android.widget.SeekBar. A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. Placing focusable widgets to the left or right of a SeekBar is discouraged.


Video Answer


2 Answers

  1. For API 11 and later, can use seekbar's XML attributes(android:rotation="270") for vertical effect.

    <SeekBar android:id="@+id/seekBar1" android:layout_width="match_parent" android:layout_height="wrap_content" android:rotation="270"/> 
  2. For older API level (ex API10), only use Selva's answer:
    https://github.com/AndroSelva/Vertical-SeekBar-Android

like image 194
Saturn Avatar answered Sep 30 '22 05:09

Saturn


Here is a very good implementation of vertical seekbar. Have a look.

http://560b.sakura.ne.jp/android/VerticalSlidebarExample.zip

And Here is my own implementation for Vertical and Inverted Seekbar based on this

https://github.com/AndroSelva/Vertical-SeekBar-Android

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:             int i=0;             i=getMax() - (int) (getMax() * event.getY() / getHeight());             setProgress(i);             Log.i("Progress",getProgress()+"");             onSizeChanged(getWidth(), getHeight(), 0, 0);             break;          case MotionEvent.ACTION_CANCEL:             break;     }     return true; } 
like image 33
Andro Selva Avatar answered Sep 30 '22 06:09

Andro Selva