Added grow animation to LrcView
This commit is contained in:
parent
956cce6989
commit
5a5b464057
4 changed files with 23 additions and 12 deletions
|
@ -88,7 +88,6 @@ static def getDate() {
|
|||
new Date().format('MMddyyyyss')
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation project(':appthemehelper')
|
||||
implementation "androidx.gridlayout:gridlayout:1.0.0"
|
||||
|
|
|
@ -167,7 +167,7 @@ class CoverLrcView @JvmOverloads constructor(
|
|||
isShowTimeline = false
|
||||
removeCallbacks(hideTimelineRunnable)
|
||||
mCurrentLine = centerLine
|
||||
invalidate()
|
||||
animateCurrentTextSize()
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
|
@ -458,6 +458,7 @@ class CoverLrcView @JvmOverloads constructor(
|
|||
mCurrentLine = line
|
||||
if (!isShowTimeline) {
|
||||
smoothScrollTo(line)
|
||||
animateCurrentTextSize()
|
||||
} else {
|
||||
invalidate()
|
||||
}
|
||||
|
@ -536,6 +537,18 @@ class CoverLrcView @JvmOverloads constructor(
|
|||
canvas.restore()
|
||||
}
|
||||
|
||||
fun animateCurrentTextSize() {
|
||||
val currentTextSize = mCurrentTextSize
|
||||
ValueAnimator.ofFloat(mNormalTextSize, currentTextSize).apply {
|
||||
addUpdateListener {
|
||||
mCurrentTextSize = it.animatedValue as Float
|
||||
invalidate()
|
||||
}
|
||||
duration = 300L
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (event.action == MotionEvent.ACTION_UP
|
||||
|
@ -613,7 +626,7 @@ class CoverLrcView @JvmOverloads constructor(
|
|||
private fun adjustCenter() {
|
||||
smoothScrollTo(centerLine, ADJUST_DURATION)
|
||||
}
|
||||
/** 滚动到某一行 */
|
||||
|
||||
/** 滚动到某一行 */
|
||||
private fun smoothScrollTo(line: Int, duration: Long = mAnimationDuration) {
|
||||
val offset = getOffset(line)
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:fel_edge="top|bottom"
|
||||
app:fel_size_bottom="80dp"
|
||||
app:fel_size_top="80dp">
|
||||
app:fel_size_bottom="100dp"
|
||||
app:fel_size_top="100dp">
|
||||
|
||||
<code.name.monkey.retromusic.lyrics.CoverLrcView
|
||||
android:id="@+id/lyricsView"
|
||||
|
|
13
build.gradle
13
build.gradle
|
@ -1,10 +1,12 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.6.10'
|
||||
ext.navigation_version = '2.4.0-rc01'
|
||||
ext.mdc_version = '1.5.0-rc01'
|
||||
ext.preference_version = '1.2.0-rc01'
|
||||
ext {
|
||||
kotlin_version = '1.6.10'
|
||||
navigation_version = '2.4.0-rc01'
|
||||
mdc_version = '1.5.0-rc01'
|
||||
preference_version = '1.2.0-rc01'
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
|
@ -17,9 +19,6 @@ buildscript {
|
|||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id "com.github.ben-manes.versions" version "0.39.0"
|
||||
}
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue