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