原项目地址:https://github.com/zhengken/LyricViewDemo

dependencies {

compile 'com.github.zhengken:LyricViewDemo:v1.0'

}

XML code

//step 1

android:id="@+id/custom_lyric_view"

android:layout_width="match_parent"

android:layout_height="match_parent" />

Java code

//step 2

LyricView mLyricView = (LyricView)findViewById(R.id.custom_lyric_view);

//step 3

mLyricView.setLyricFile(lyricFile);

//step 4, update LyricView every interval

mLyricView.setCurrentTimeMillis(progress);

//step 5, implement the interface when user drag lyrics and click the play icon

mLyricView.setOnPlayerClickListener(new LyricView.OnPlayerClickListener() {

@Override

public void onPlayerClicked(long progress, String content) {

}

});

XML attributes

AttributesFormatDefaultDescription

fadeInFadeOutbooleanfalseEnable lyrics fadeInFadeOut or not

hintstringNo LyricsDisplay when not exist lyric file

hintColorcolor#FFFFFFThe color of hint text

textSizedimension16spThe text size of lyrics

textColorcolor#8D8D8DThe color of lyrics

highlightColorcolor#FFFFFFThe color of current lyric that playing

textAlignenumCENTERThe alignment of lyrics

maxLengthdimension300dpLine feed when lyric'width beyond maxLength

lineSpacedimension25dpLine space

Java API

MethodsDescription

setOnPlayerClickListener(OnPlayerClickListener listener)Callback when click the play icon

setAlignment(@Alignment int alignment)Set the alignment of the lyrics

setCurrentTimeMillis(long current)Scroll lyrics to the specify TimeMillis

setLyricFile(File file)Set the lyric file, and auto set the charset by juniversalchardet-1.0.3

setLyricFile(File file, String charset)Set the lyric file with the specified charset

setTypeface(Typeface typeface)Set the typeface of lyrics

reset()Reset the LyricView

Thanks

更多相关文章

  1. Android学习视频
  2. Android获取物理地址(支持5.0~10.0)
  3. Android(安卓)Studio 关联项目软链接
  4. Android(安卓)Studio开发(二)使用RecyclerView实现瀑布流展示
  5. Android(安卓)start from now on
  6. Android第三十一期 - 市面上所有引导页的效果
  7. reactNative 集成支付宝支付
  8. Android项目集成Flutter
  9. Android获取声音长度

随机推荐

  1. Android经典项目案例开发实战宝典
  2. 《BAT大咖助力 全面升级Android面试笔记
  3. android 版本更新和下载安装 适配android
  4. 转 android launch flow
  5. phonegap底层原理学习和研究(一)
  6. android LinearLayout添加分隔线
  7. AsyncTask使用和源码解析
  8. android 反编译
  9. golang开发android应用(二) - go语言生成an
  10. Android分享新浪微博