WaveView
有一天祭埂,UI腦洞大開,想設(shè)計(jì)一個炫酷的個人信息界面兵钮,嗯蛆橡,波浪流動的動態(tài)效果背景不錯,做一個這個吧:
UI說掘譬,我給幾張圖泰演,你自己挪吧。
作為一個有靈魂的程序員葱轩,我立馬say NO睦焕!
于是,波浪流動的動態(tài)效果的自定義控件應(yīng)運(yùn)而生酿箭。
希望有人會喜歡~
Gradle Build
Step 1. Add the JitPack repository to your build file
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 {
compile 'com.github.SenhLinsh:WaveView:1.0.0'
}
How To Use
XML:
<com.linsh.waveview.WaveView
android:id="@+id/waveview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Activity:
int color = Color.parseColor("#55303F9F");
Wave wave1 = new Wave(1080, 30, 5, 45, color);
Wave wave2 = new Wave(1620, 26, -6, 50, color);
Wave wave3 = new Wave(2080, 3, 3, 300, color);
waveView.addWave(wave1);
waveView.addWave(wave2);
waveView.addWave(wave3);
or
LinearGradient shader = new LinearGradient(0, 0, 0, 1920, Color.parseColor("#303F9F"), Color.parseColor("#553F51B5"), Shader.TileMode.CLAMP);
PercentWave wave1 = new PercentWave(1.50f, 0.03f, 0.018f, 0.11f, shader);
PercentWave wave2 = new PercentWave(1.28f, 0.02f, -0.02f, 0.12f, shader);
PercentWave wave3 = new PercentWave(2.08f, 0.01f, 0.01f, 0.20f, shader);
waveView.addWave(wave1);
waveView.addWave(wave2);
waveView.addWave(wave3);