android编程歌词显示,LyricView一个用来在Android音乐播放器中显示歌词自定义视图...

625332134c6f4d4600884b99daebf603.png

LyricView

LyricView is a powerful and flexible custom view to display lyrics within music player under Android

Screenshot

Usage

Gradle dependency

step 1 Add the JitPack repository to your build file

allprojects {

repositories {

...

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

}

}

step 2 Add the dependency

dependencies {

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

}

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

Attributes

Format

Default

Description

fadeInFadeOut

boolean

false

Enable lyrics fadeInFadeOut or not

hint

string

No Lyrics

Display when not exist lyric file

hintColor

color

#FFFFFF

The color of hint text

textSize

dimension

16sp

The text size of lyrics

textColor

color

#8D8D8D

The color of lyrics

highlightColor

color

#FFFFFF

The color of current lyric that playing

textAlign

enum

CENTER

The alignment of lyrics

maxLength

dimension

300dp

Line feed when lyric'width beyond maxLength

lineSpace

dimension

25dp

Line space

Java API

Methods

Description

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

License

Copyright 2016 zhengken

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值