Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>public class VerticalSeekBar extends SeekBar { public VerticalSeekBar(Context context) { super(context); } public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public VerticalSeekBar(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: 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; } } </code></pre> <p>and in your layout use this</p> <pre><code> &lt;youpackagename.VerticalSeekBar android:id="@+id/seek" android:layout_width="wrap_content" android:layout_height="wrap_content" android:progressDrawable="@drawable/seekbar_bg" android:thumb="@drawable/seekbar_control" /&gt; </code></pre> <p>seekbar_bg.xml</p> <pre><code>&lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:id="@android:id/background"&gt; &lt;shape&gt; &lt;corners android:radius="5dip" /&gt; &lt;gradient android:angle="270" android:centerColor="#0F0F0F" android:centerY="0.75" android:endColor="#000000" android:startColor="#000000" /&gt; &lt;/shape&gt; &lt;stroke android:width="2dp" android:color="#0F0F0F"/&gt; &lt;/item&gt; &lt;item android:id="@android:id/progress"&gt; &lt;clip&gt; &lt;shape&gt; &lt;corners android:radius="5dip" /&gt; &lt;gradient android:angle="270" android:centerColor="#22e4fa" android:centerY="0.75" android:endColor="#01a5db" android:startColor="#0294d5" /&gt; &lt;/shape&gt; &lt;/clip&gt; &lt;/item&gt; &lt;/layer-list&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload