=====================mainactivity======================
package com.example.lenovo.jiugongge;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements Myjiugongge.OnPatternChangeListener {
private TextView tv;
private Myjiugongge lpv;
int patt=123456789;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lpv = (Myjiugongge) findViewById(R.id.lock_pattern_view);
tv = (TextView) findViewById(R.id.text);
lpv.setOnPatternChangeListener(this);
}
@Override
public void onPatternChange(String patternPassword) {
if(patternPassword==null){
tv.setText("请至少5个点");
}else{
tv.setText(patternPassword);
}
}
@Override
public void onPatternStarted(boolean isStarted) {
if(isStarted){
tv.setText("请绘制图案");
}
}
}
======================Myjiugongge===================
package com.example.lenovo.jiugongge;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import java.util.ArrayList;
/**
* Created by W on 2017/12/1.
*/
public class Myjiugongge extends View{
// 正常状态的颜色
private static final int SELECTED_COLOR = 0xFF979797;
// 正常状态的颜色
private static final int NORMAL_COLOR = 0xFF70DBDB;
private Paint mCiclePaint;
private Paint mLinePoaint;
private float mRadius;
//圆心数组
private PointView[][] mPointViewArray = new PointView[3][3];
//保存选中点的集合
private ArrayList<PointView> mSelectedPointViewList;
//解锁团的边长
private int mPatternWidth;
//每个圆圈的下标
private int mIndex = 1;
//正在滑动 并且没有任何点选中
private boolean mIsMovingWithoutCircle = false;
//是否绘制结束
private boolean