Code Monkey home page Code Monkey logo

lrcview's Introduction

LrcView



这是使用非常简单而且效果还不错的Android歌词控件,只需要传递歌词文件,即可实现类似网易云音乐的歌词效果,拓展性强,可以根据需求自定义显示设置。

支持效果有:

1.柔和的滑动到指定时间歌词。
2.手势拖动歌词控件,释放手势跳转歌词。
3.提供自定义歌词大小字体颜色等,方便自定义界面。
4.对于超长歌词换行显示。
5.支持滑动条颜色大小以及是否显示等设置
6.可以添加自定义解析器满足特定需求



imag

imag



使用方法:

依赖

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}



dependencies {
	        compile 'com.github.bifan-wei:LrcView:V1.3'
	}

代码使用

xml:

 <com.hw.lrcviewlib.LrcView
  android:id="@+id/au_lrcView"
  android:layout_width="match_parent"
  android:layout_height="match_parent" />


设置数据:

 
        List<LrcRow> lrcRows = new LrcDataBuilder().BuiltFromAssets(this, "test2.lrc");
         //ro  List<LrcRow> lrcRows = new LrcDataBuilder().Build(file);
        //mLrcView.setTextSizeAutomaticMode(true);//是否自动适配文字大小
	
        //init the lrcView
        mLrcView.getLrcSetting()
                .setTimeTextSize(40)//时间字体大小
                .setSelectLineColor(Color.parseColor("#ffffff"))//选中线颜色
                .setSelectLineTextSize(25)//选中线大小
                .setHeightRowColor(Color.parseColor("#aaffffff"))//高亮字体颜色
                .setNormalRowTextSize(DisPlayUtil.sp2px(this, 17))//正常行字体大小
                .setHeightLightRowTextSize(DisPlayUtil.sp2px(this, 17))//高亮行字体大小
                .setTrySelectRowTextSize(DisPlayUtil.sp2px(this, 17))//尝试选中行字体大小
                .setTimeTextColor(Color.parseColor("#ffffff"))//时间字体颜色
                .setTrySelectRowColor(Color.parseColor("#55ffffff"));//尝试选中字体颜色
		
        mLrcView.commitLrcSettings();
        mLrcView.setLrcData(lrcRows);


歌词拖动监听:

        mLrcView.setLrcViewSeekListener(new ILrcViewSeekListener() {
            @Override
            public void onSeek(LrcRow currentLrcRow, long CurrentSelectedRowTime) {
                //在这里执行播放器控制器控制播放器跳转到指定时间
                mController.seekTo((int) CurrentSelectedRowTime);
            }
        });


歌词跳柔和滑动转到指定时间:

//播放器播放时,时间更新后调用这个时歌词数据更新到当前对应的歌词,播放器一般时间更新以秒为频率更新
mLrcView.smoothScrollToTime(time)//传递的数据是播放器的时间格式转化为long数据

lrcview's People

Contributors

bifan-wei avatar huangwei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.