Skip to content

Commit 55442f8

Browse files
author
luck
committed
V1.0.2
1 parent cd048bc commit 55442f8

File tree

1 file changed

+12
-2
lines changed
  • splitview/src/main/java/com/luck/view/splitview

1 file changed

+12
-2
lines changed

splitview/src/main/java/com/luck/view/splitview/Split.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.content.Context;
44
import android.content.res.TypedArray;
55
import android.graphics.Canvas;
6+
import android.graphics.Color;
7+
import android.graphics.Paint;
68
import android.graphics.Rect;
79
import android.util.AttributeSet;
810
import android.view.MotionEvent;
@@ -27,6 +29,7 @@ public class Split {
2729
private int width = -1, height = -1;
2830
private List<Rect> mRects = new ArrayList<>();
2931
private List<FRect> mFRects;
32+
private Rect mRect;
3033
private float mTouchX;
3134
private float mTouchY;
3235

@@ -97,6 +100,12 @@ protected void setOtherStyle(List<FRect> fRects) {
97100

98101

99102
protected void onDraw(Canvas canvas) {
103+
if (mRect != null) {
104+
Paint paint = new Paint();
105+
paint.setColor(Color.BLUE);
106+
paint.setAlpha(180);
107+
canvas.drawRect(mRect, paint);
108+
}
100109
}
101110

102111
private boolean isclick = false;//是否正在执行点击事件
@@ -116,6 +125,7 @@ protected void onTouchEvent(MotionEvent event, View view) {
116125
if (myRect.contains((int) mTouchX, (int) mTouchY)) {
117126
ischeckposition = true;
118127
position = i;
128+
mRect = myRect;
119129
view.invalidate();
120130
break;
121131
}
@@ -126,9 +136,9 @@ protected void onTouchEvent(MotionEvent event, View view) {
126136
}
127137
break;
128138
case MotionEvent.ACTION_UP:
129-
case MotionEvent.ACTION_POINTER_UP:
130-
case MotionEvent.ACTION_CANCEL:
131139
isclick = false;
140+
mRect = null;
141+
view.invalidate();
132142
break;
133143
}
134144
}

0 commit comments

Comments
 (0)