Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@o4oren
Created May 2, 2020 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save o4oren/dafb5d702ad4465e9ad506f6c9672ef7 to your computer and use it in GitHub Desktop.
Save o4oren/dafb5d702ad4465e9ad506f6c9672ef7 to your computer and use it in GitHub Desktop.
RotartyKnob initialization
init {
this.maxValue = maxValue + 1
LayoutInflater.from(context)
.inflate(R.layout.rotary_knob_view, this, true)
context.theme.obtainStyledAttributes(
attrs,
R.styleable.RotaryKnobView,
0,
0
).apply {
try {
minValue = getInt(R.styleable.RotaryKnobView_minValue, 0)
maxValue = getInt(R.styleable.RotaryKnobView_maxValue, 100) + 1
divider = 300f / (maxValue - minValue)
value = getInt(R.styleable.RotaryKnobView_initialValue, 50)
knobDrawable = getDrawable(R.styleable.RotaryKnobView_knobDrawable)
knobImageView.setImageDrawable(knobDrawable)
} finally {
recycle()
}
}
gestureDetector = GestureDetectorCompat(context, this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment