There is an excellent example of commatization on the git , with 1300 rating stars, but I have not found a single function that could correctly make it vertical ...
When I add a parameter
android:rotation="-90" It turns, but at the same time it continues to occupy a place as if it is located horizontally ... If you decrease the space horizontally, then when shown vertically, it also decreases ...
In general, the example is very cool and you really need to turn it so that everything works correctly, tell me how it can be done? Maybe in some sort of container to put it?
Override Class Code
public class VerticalDiscreteSeekBar extends DiscreteSeekBar { public VerticalDiscreteSeekBar(Context context) { super(context); } public VerticalDiscreteSeekBar(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalDiscreteSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } 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; } } XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".tools.TestDeleteIt"> <com.example.android.camera2basic.tools.VerticalDiscreteSeekBar android:layout_width="match_parent" android:layout_height="match_parent" app:dsb_thumbColor="@color/color_white" app:dsb_indicatorColor="@color/color_white" app:dsb_indicatorFormatter="%03d" app:dsb_indicatorTextAppearance="@style/CustomFloaterTextAppearance" app:dsb_max="14" app:dsb_min="-14" app:dsb_progressColor="@color/ntz_color_yellow" app:dsb_rippleColor="@color/ntz_color_yellow" app:dsb_scrubberHeight="10dp" app:dsb_thumbSize="25dp" app:dsb_trackColor="@color/ntz_color_yellow" app:dsb_trackHeight="10dip"/> </LinearLayout> and the screen as it looks (sort of shows that there is something there, but in fact does not display anything ...) 