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



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

Github上有一个比较有趣的Android第三方开源波形view:WaveView,这种WaveView在一些常见的APP开发中,以水面波浪波形的形象的生动展示手机还剩余多少电量,存储容量还有多少,比较形象直观生动。
如图:


WaveView在github上的项目主页是:https://github.com/john990/WaveView
WaveView首先需要在布局中定义:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:wave="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.john.waveview.WaveView
        android:id="@+id/wave_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        wave:above_wave_color="#e53935"
        wave:blow_wave_color="#e53935"
        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="100" />
</FrameLayout>


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


wave_height
定义波浪的高度。


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



wave_length
定义波浪的长度。


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


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



以一个seekbar调整WaveView的代码为例:

package com.waveview.demo;

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.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) {

            }
        });
    }
}

转载于:https://my.oschina.net/zhangphil/blog/1602052

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值