The video Player page Volume Control Seekbar
achieves a vertical effect. Vertical just will be Seekbar
90 degrees or 90 degrees, we can turn the canvas to an angle, and then to the system to draw, the concrete way is to rewrite the ondraw()
adjustment canvas, and then call super.onDraw()
.
Up the Seekbar
protected void OnDraw (Canvas c) { c.rotate (-90); C.translate (-height,0); // height is the height of your Verticalseekbar Super . OnDraw (c);}
The downward seekbar should be:
protected void OnDraw (Canvas c) { c.rotate (+); C.translate (0,-width); // width is the width of your Verticalseekbar Super . OnDraw (c);}
Sample code
Public classVerticalseekbarextendsSeekBar { PublicVerticalseekbar (Context context) {Super(context); } PublicVerticalseekbar (context context, AttributeSet attrs,intDefstyle) { Super(context, attrs, Defstyle); } PublicVerticalseekbar (Context context, AttributeSet attrs) {Super(context, attrs); } protected voidOnsizechanged (intWintHintOLDW,intOLDH) { Super. Onsizechanged (H, W, OLDH, OLDW); } @Overrideprotected synchronized voidOnmeasure (intWidthmeasurespec,intHeightmeasurespec) { Super. Onmeasure (Heightmeasurespec, Widthmeasurespec); Setmeasureddimension (Getmeasuredheight (), Getmeasuredwidth ()); } protected voidOnDraw (Canvas c) {c.rotate (-90); C.translate (-getheight (), 0); Super. OnDraw (c); } @Override Public synchronized voidSetprogress (intprogress) { Super. Setprogress (progress); Onsizechanged (GetWidth (), GetHeight (),0, 0); } @Override Public Booleanontouchevent (Motionevent event) {if(!isenabled ()) { return false; } Switch(Event.getaction ()) { CaseMotionevent.action_down: CaseMotionevent.action_move: CaseMotionEvent.ACTION_UP:setProgress ((int) ((int) Getmax ()-(Getmax () * event.gety ()/getheight ()))); Break; default: return Super. Ontouchevent (event); } return true; } }
The Upright Seekbar