Android GestureOverlayView 参数

Android GestureOverlayView parameters

我开始尝试自定义手势和 GestureOverlayView 并注意到一些变量,我不确定它们的用途以及可以和应该分配的值范围,文档似乎对这些变量有些模糊:

//Minimum curve angle a stroke must contain before it is recognized as a gesture. 
android:gestureStrokeAngleThreshold

I assumed this is in degrees and when I add "25" here, a sharp edge must be contained in the gesture, but actually it still is detected ifI draw a circle or a perfect square.

//Minimum length of a stroke before it is recognized as a gesture. 
android:gestureStrokeLengthThreshold    

Is this in dp ? Because it seems like on smaller screens it is harder to trigger the gesture...

//Squareness threshold of a stroke before it is recognized as a gesture. 
android:gestureStrokeSquarenessThreshold

what is this?

编辑:

好吧,我刚刚意识到每个预测都有一个分数值,应该用来确定执行的手势是否确实符合要求,所以我添加了一个检查预测的分数是否大于 1。

我还是很好奇 GestureOverlayView 中的那些变量在做什么,所以请赐教:)

gestureStrokeLengthThreshold 绝对不是密度独立的,但显然使用像素。如果您想设置一个与密度无关的阈值,您可以在运行时计算 gestureStrokeLengthThreshold,如下所示:

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    float normalizedScreenSize = (metrics.heightPixels + metrics.widthPixels) / 2.0f;
    return normalizedScreenSize * GESTURE_LENGTH_THRESHOLD;

GESTURE_LENGTH_THRESHOLD 将是一个表示手势应该有多长的值。值 1.0 大致是屏幕的大小(屏幕宽度和高度的平均值)

我仍然对 GestureOverlayView 中的其他变量的作用很感兴趣,所以如果你知道更多 - 请赐教 :)