"android vertical seekbar" Code Answer's

You're definitely familiar with the best coding language Kotlin that developers use to develop their projects and they get all their queries like "android vertical seekbar" answered properly. Developers are finding an appropriate answer about android vertical seekbar related to the Kotlin coding language. By visiting this online portal developers get answers concerning Kotlin codes question like android vertical seekbar. Enter your desired code related query in the search bar and get every piece of information about Kotlin code related question on android vertical seekbar. 

android vertical seekbar

By Ali GAli G on Jan 30, 2021
import android.content.Context
import android.graphics.Canvas
import android.util.AttributeSet
import android.view.MotionEvent


class VerticalSeekBar : androidx.appcompat.widget.AppCompatSeekBar {
    private var changeListener: OnSeekBarChangeListener? = null
    private var x = 0
    private var y = 0
    private var z = 0
    private var w = 0

    constructor(context: Context) : super(context) {}
    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
        context,
        attrs,
        defStyle
    ) {
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}

    @Synchronized
    override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
        super.onSizeChanged(h, w, oldh, oldw)
        x = w
        y = h
        z = oldw
        this.w = oldh
    }

    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        super.onMeasure(heightMeasureSpec, widthMeasureSpec)
        setMeasuredDimension(measuredHeight, measuredWidth)
    }

    override fun onDraw(c: Canvas) {
        c.rotate(-90f)
        c.translate(-height.toFloat(), 0f)
        super.onDraw(c)
    }

    override fun onTouchEvent(event: MotionEvent): Boolean {
        if (!isEnabled) {
            return false
        }
        when (event.action) {
            MotionEvent.ACTION_DOWN -> {
                isSelected = true
                isPressed = true
                if (changeListener != null) changeListener!!.onStartTrackingTouch(this)
            }
            MotionEvent.ACTION_UP -> {
                isSelected = false
                isPressed = false
                if (changeListener != null) changeListener!!.onStopTrackingTouch(this)
            }
            MotionEvent.ACTION_MOVE -> {
                val progress = (max
                        - (max * event.y / height).toInt())
                setProgress(progress)
                onSizeChanged(width, height, 0, 0)
                if (changeListener != null) changeListener!!.onProgressChanged(this, progress, true)
            }
            MotionEvent.ACTION_CANCEL -> {
            }
        }
        return true
    }

    @Synchronized
    override fun setOnSeekBarChangeListener(
        listener: OnSeekBarChangeListener
    ) {
        changeListener = listener
    }

    @Synchronized
    override fun setProgress(progress: Int) {
        if (progress >= 0) super.setProgress(progress) else super.setProgress(0)
        onSizeChanged(x, y, z, w)
        if (changeListener != null) changeListener!!.onProgressChanged(this, progress, false)
    }
}

Source: github.com

Add Comment

1

All those coders who are working on the Kotlin based application and are stuck on android vertical seekbar can get a collection of related answers to their query. Programmers need to enter their query on android vertical seekbar related to Kotlin code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about android vertical seekbar for the programmers working on Kotlin code while coding their module. Coders are also allowed to rectify already present answers of android vertical seekbar while working on the Kotlin language code. Developers can add up suggestions if they deem fit any other answer relating to "android vertical seekbar". Visit this developer's friendly online web community, CodeProZone, and get your queries like android vertical seekbar resolved professionally and stay updated to the latest Kotlin updates. 

Kotlin answers related to "android vertical seekbar"

View All Kotlin queries

Kotlin queries related to "android vertical seekbar"

android vertical seekbar seekbar kotlin android studio keep device awake disable portrait mode android android recyclerview scroll to bottom coroutines kotlin android dependency how to call a function after delay in kotlin android android custom AlertDialog theme android is valid email android long to duration string android startActivity and close all the others android disable landscape mode android send email intent with chooser exported android manifest android webview kotlin implement spinner in android kotlin android mailto intent spinner selected item listener android kotlin close dialog android kotlin android click again to exit status bar color android kotlin play sound android studio kotlin android kotlin cannot @+id in MainActivity how to make dialog transparent android android popup menu kotlin kotlin copy text android 10 set margin programmatically android kotlin android start new Activity from an activity with a child change spinner text color android kotlin hide keyboard suggestion android kotlin android kotlin set timerout search bar android studio kotlin android kotlin Avoid passing null as the view root AlertDialog observable kotlin android button inside a recycle view in android in kotlin custom listview in android kotlin with baseadapter with clicklistener android bottomnavigationview leaves blank space after full screen android studio add line at end of class android prevent screenshot in activity android listview search filter custom adapter kotlin how to make a delay in android kotlin android kotlin timer hide keyboard android kotlin kotlin android string resource time text format kotlin android studio android navigation drawer not navigating with navcontroller

Browse Other Code Languages

CodeProZone