水面波浪形View--第三方开源--WaveView(电量、能量、容量指示)

来源:互联网 发布:apache post请求 编辑:程序博客网 时间:2024/05/05 13:15

这种WaveView在一些常见的APP开发中,以水面波浪波形的形象的生动展示手机还剩余多少电量,存储容量还有多少,比较形象直观生动。

WaveView在github上的项目主页是:https://github.com/john990/WaveView 

代码:

 

 

activity_main.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:wave="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent" >    <!-- wave:above_wave_color-->    <!-- wave:blow_wave_color 定义波形的颜色 ,顶部波形平面的下方 -->    <!-- wave_height 定义波浪的高度 -->    <!-- wave_hz 定义波浪起伏的频率赫兹。 -->    <!-- wave_length 定义波浪的长度 -->    <!-- wave:progress 为整型值,以0-100,100表示最高位波浪,0表示最低波浪 -->    <com.john.waveview.WaveView        android:id="@+id/wave_view"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:background="#1565C0"        wave:blow_wave_color="#1A237E"        wave:progress="60"        wave:wave_height="large"        wave:wave_hz="normal"        wave:wave_length="middle" />    <SeekBar        android:id="@+id/seek_bar"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_gravity="bottom|center_horizontal"        android:layout_marginBottom="20dp"        android:progress="60" /></FrameLayout>

MainActivity:

package com.zzw.testwaveview;import android.app.Activity;import android.os.Bundle;import android.widget.SeekBar;import com.john.waveview.WaveView;public class MainActivity extends Activity {    private SeekBar seekBar;    private WaveView waveView;    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        seekBar = (SeekBar) findViewById(R.id.seek_bar);        waveView = (WaveView) findViewById(R.id.wave_view);        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {            @Override            public void onProgressChanged(SeekBar seekBar, int progress,                    boolean fromUser) {                waveView.setProgress(progress);            }            @Override            public void onStartTrackingTouch(SeekBar seekBar) {            }            @Override            public void onStopTrackingTouch(SeekBar seekBar) {            }        });    }}




0 0
原创粉丝点击