前言
項目中有語音錄入文字的功能,需要一個動畫效果。所以需要實現(xiàn)一個隨音頻大小而改變的波浪圖形。是基于A memory-friendly recording wave animation一款性能內(nèi)存友好的錄音波浪動畫的基礎(chǔ)上進行修改完成的。感謝這位大神,原理講解請看這里。
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ù)聲音大小進行設(shè)置
waveLineView.setVolume((int) db);