LyricViewX is a beautiful Lyrics control for Android.
Based on LrcView design.
Step 1. Add the JitPack repository to the build file Add it to build.gradle(root) :
allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
}
}
Step 2. Add dependencies
dependencies {
implementation 'com.github.Moriafly:LyricViewX:#Tag' // replace $Tag with lastest version
}
<com.dirror.lyricviewx.LyricViewX
android:id="@+id/lyricViewX"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:lrcPadding="16dp">
</com.dirror.lyricviewx.LyricViewX>
val lyricViewX = findViewById<LyricViewX>(R.id.lyricViewX)
lyricViewX.loadLyric()
/**
* Set font color for non-current line lyrics [normalColor]
*/
fun setNormalColor(normalColor: Int)
/**
* font size of normal lyrics text [size], unit px
*/
fun setNormalTextSize(size: Float)
/**
* Current text size of lyrics
*/
fun setCurrentTextSize(size: Float)
/**
* Sets the font color for the current line of lyrics
*/
fun setCurrentColor(currentColor: Int)
/**
* Sets the font color selected when dragging lyrics
*/
fun setTimelineTextColor(timelineTextColor: Int)
/**
* Sets the color of the timeline when dragging lyrics
*/
fun setTimelineColor(timelineColor: Int)
/**
* Sets the font color to the right when dragging lyrics
*/
fun setTimeTextColor(timeTextColor: Int)
/**
* Set lyrics to the text [label] displayed in the center of the screen when empty, such as "No lyrics yet".
*/
fun setLabel(label: String)
/**
* Load the lyrics file
* Lyric timestamps need to be consistent in both languages
* @param mainLyricFile First language lyrics file
* @param secondLyricFile Optional, second language song lyrics file
*/
fun loadLyric(mainLyricFile: File, secondLyricFile: File? = null)
/**
* Load the lyric text
* Lyric timestamps need to be consistent in both languages
* @param mainLyricText First language lyric text
* @Param secondLyricText optional, second language lyric text
*/
fun loadLyric(mainLyricText: String?, secondLyricText: String? = null)
/**
* Load online lyrics
* @Param lyricUrl The web address of the lyrics file
* @param charset encoding format
*/
fun loadLyricByUrl(lyricUrl: String, charset: String? = "utf-8")
/**
* Refresh lyrics
* @param time Current playback time
*/
fun updateTime(time: Long)
/**
* Sets whether dragging of lyrics is allowed
* @Param draggable whether dragging is allowed
* @Param onPlayClickListener sets lyrics drag after playback button click listener, if drag is allowed, it cannot be null
*/
fun setDraggable(draggable: Boolean, onPlayClickListener: OnPlayClickListener?)
/**
* Set click
*/
fun setOnSingerClickListener(onSingerClickListener: OnSingleClickListener?)
/**
* @NewAdded
* Get the current lyrics of each line entity, can be used for lyrics sharing
* @Return LyricEntry collection
*/
fun getLyricEntryList(): List<LyricEntry>
/**
* When the play button is clicked, it should jump to the specified play position
* @return whether the event was successfully consumed, if so, the UI will be updated
*/
fun onPlayClick(time: Long): Boolean
/**
* Click events
*/
fun onClick()
If you want to use a custom scroll interpolator, you can use the following code:
// Set the custom interpolator
val interpolator = LinearInterpolator()
lyricViewX.smoothScrollInterpolator = interpolator
LyricViewX Copyright (C) 2021-2022 Moriafly
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.