您的位置:首页 > 其它

第三方开源水面波浪波形view:WaveView

2015-11-24 17:39 337 查看
一个比较有趣的Android第三方开源波形view:WaveView,这种WaveView在一些常见的APP开发中,以水面波浪波形的形象的生动展示手机还剩余多少电量,存储容量还有多少等,比较形象直观生动。

下载地址:点此下载

wave:above_wave_color wave:blow_wave_color 定义波形的颜色(顶部波形平面的下方)。

wave_height 定义波浪的高度。

wave_hz 定义波浪起伏的频率赫兹。

wave_length 定义波浪的长度。

以上几种波浪波形为几种枚举类型。

wave:progress 为整型值,以0-100,100表示最高位波浪,0表示最低波浪。

xml文件:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:wave="http://schemas.android.com/apk/res-auto"
android:id="@+id/FrameLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.john.waveview.WaveView
android:id="@+id/wv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
wave:above_wave_color="#4CAF50"
wave:blow_wave_color="#f44336"
wave:progress="60"
wave:wave_height="large"
wave:wave_hz="normal"
wave:wave_length="middle" />

<SeekBar
android:id="@+id/sb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:progress="100" />

</FrameLayout>


package com.lixu.boliang;

import com.john.waveview.WaveView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class MainActivity extends Activity {
WaveView wv;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

wv = (WaveView) findViewById(R.id.wv);

SeekBar sb = (SeekBar) findViewById(R.id.sb);

sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// 进度条改变设置波浪
wv.setProgress(progress);
}
});

}

}


运行效果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: