前言
項(xiàng)目中有語(yǔ)音錄入文字的功能,需要一個(gè)動(dòng)畫效果。所以需要實(shí)現(xiàn)一個(gè)隨音頻大小而改變的波浪圖形。是基于A memory-friendly recording wave animation一款性能內(nèi)存友好的錄音波浪動(dòng)畫的基礎(chǔ)上進(jìn)行修改完成的。感謝這位大神,原理講解請(qǐng)看這里。
github地址:https://github.com/lzy2626/WaveLine
看一下效果圖:
GIF.gif
使用方式:
Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.lzy2626:WaveLine:Tag'
}
Step 3.xml
<com.lzy.waveline.WaveLineView
android:id="@+id/waveLineView"
android:layout_width="match_parent"
android:layout_height="200dp"
app:wlvBackgroundColor="@android:color/white" />
Step 4.activity
waveLineView = (WaveLineView) findViewById(R.id.waveLineView);
waveLineView.startAnim();
//根據(jù)聲音大小進(jìn)行設(shè)置
waveLineView.setVolume((int) db);