"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
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
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.