Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.onlynight:WaveView:1.0.0'
}
in your xml file:
<com.github.onlynight.waveview.WaveView
android:id="@+id/waveView1"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"app:isCircle="false"app:period="4"app:waveHeightPercent="0.5"app:waveRange="15dp"app:waveSpeed="10"app:waveStrokeWidth="3dp"/>in your java code file:
mWaveView1 = (WaveView) findViewById(R.id.waveView1);
mWaveView1.start();<declare-styleablename="WaveView">
<!-- define wave speed, example value 10 -->
<attrname="waveSpeed"format="float"/>
<!-- define wave range, example value 15dp -->
<attrname="waveRange"format="dimension|reference"/>
<!-- define wave 1 color -->
<attrname="wave1Color"format="color|reference"/>
<!-- define wave 2 color -->
<attrname="wave2Color"format="color|reference"/>
<!-- define wave height percent, the value is between 0 to 1 -->
<attrname="waveHeightPercent"format="float"/>
<!-- define paint stroke width, if you want optimizing view, you should change the stroke width more-->
<attrname="waveStrokeWidth"format="dimension|reference"/>
<!-- if the view is circle -->
<attrname="isCircle"format="boolean"/>
<!-- the sine wave period, value range 0 to all -->
<attrname="period"format="float"/>
</declare-styleable>
