最新Android9开发之多点触控画图划线实例讲解(可以用于LCD屏幕测试)
XML布局文件
首先看布局文件,直接上代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".touch_text_Activity">
<com.example.lcd.BezierGestureTrackView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
简单解释一下:
1.采用了ConstraintLayout的布局,布局中只有一个自定义的控件名叫BezierGestureTrackView;
2.要引用自定义控件,就必须写出完整的包名,这里是com.example.lcd.BezierGestureTrackView;
接下来我们就看一下这个自定义控件
自定义控件BezierGestureTrackView
public class BezierGestureTrackView extends View {
public BezierGestureTrackView(Context context) {
super(context);
}
Paint paint;
public BezierGestureTrackView(Context context, AttributeSet attrs) {
super(context, attrs);
paint