原项目地址: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获取物理地址(支持5.0~10.0)
  2. Android Studio 关联项目软链接
  3. eclipse android 项目报错 ERROR: Unable to open class file
  4. Android常用技术、常用工具和开源项目
  5. Android多功能课程表项目实现(完整版)
  6. Android 获取IP地址的实现方法
  7. Android学习实践:1.初次创建Android项目遇到的各种问题
  8. Android 项目打包成apk文件
  9. Android Studio-Gradle项目中添加libs目录

随机推荐

  1. Android开发中Material Design风格设置页
  2. Android(安卓)Studio的快捷键
  3. Android之常见图标尺寸
  4. 自定义字体主题+自定义背景+设置radiobut
  5. Android(安卓)设计模式之适配器模式
  6. Android(安卓)Studio配置打包生成自定义
  7. Android(安卓)Handler和内部类的正确用法
  8. [置顶] Android-仿小米巨无霸字体调整控
  9. Android(安卓)xml 格式 随笔
  10. Android网络编程基础(一) - 基础知识