Last active
December 5, 2019 23:46
-
-
Save omidMirrajei/c9e8fa439ecfbe02647f0ee01e4f9dea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val initialTextViewTranY = textView_progress.translationY | |
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { | |
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { | |
textView_progress.text = progress.toString() | |
val translationDistance = (initialTextViewTranY + | |
progress * resources.getDimension(R.dimen.text_anim_stem) * -1) | |
textView_progress.animate().translationY(translationDistance) | |
if (!fromUser) | |
textView_progress.animate().setDuration(500).rotationBy(360f) | |
.translationY(initialTextViewTranY) | |
} | |
override fun onStartTrackingTouch(seekBar: SeekBar?) | |
override fun onStopTrackingTouch(seekBar: SeekBar?) | |
}) | |
button_reset.setOnClickListener { seekBar.progress = 0 } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment