wxr
2022-10-28 bab36f8002d92e7125dfc40023f566266e3fdb38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.mm.android.deviceaddmodule.mobilecommon.widget.linechart.charts;
 
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
 
 
public abstract class Chart extends View {
 
    public Chart(Context context) {
        this(context, null, 0);
    }
 
    public Chart(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }
 
    public Chart(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
    }
 
 
    protected void init(Context context, AttributeSet attrs) {
        // 采用硬件加速
        setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
 
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 
        int size = 100;
        int width = resolveSize(size, widthMeasureSpec);
        int height = resolveSize(size, heightMeasureSpec);
 
        setMeasuredDimension(width, height);
    }
 
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
    }
}