效果图:
页面布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_145"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/white">
<TextView
android:id="@+id/tv_index"
android:layout_width="@dimen/dp_30"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/common_btn_clicked"
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/sp_14"
tools:text="TH"/>
<RelativeLayout
android:id="@+id/rl_wave_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<com.kl.common_base.view.wave.GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:bgColor="#f0d3a9"/>
<com.kl.common_base.view.wave.PdfEcgWaveView
android:id="@+id/wave_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
<TextView
android:id="@+id/tv_file_create_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10"
android:text=""
android:textColor="@color/colorPrimary"
android:textSize="@dimen/sp_12"
tools:text="2019年6月26日11:54" />
</RelativeLayout>
</LinearLayout>
自定义波形图控件:
package com.kl.common_base.view.wave;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.kl.common_base.R;
import com.kl.common_base.utils.SizeUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class PdfEcgWaveView extends View {
private List<Short> pointList = Collections.synchronizedList(new LinkedList<>());
private Paint mPaint;
private Paint mPaintLine;
private int mWidth = 0;
private int mHeight = 0;
private int mCenterY = 0;
public float points[];
List<Short> nativeDatas = null;
private int len = 0;
private int index = 0;
private int zoom;
private float gapX