GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 修改图片显示一般松手后再次下拉需滑动一段距离才能放大图片问题,即手指松开后未清空状态导致的问题 · tmexcept/AndroidCustomView@1c58c24

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • app/src/main/java/com/allen/android/coordinatorzoom
    • CustomCoordinatorLayout.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎app/src/main/java/com/allen/android/coordinatorzoom/CustomCoordinatorLayout.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/allen/android/coordinatorzoom/CustomCoordinatorLayout.java
+16-8Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void setmMoveView(View mMoveView1,View mMoveView2) {
5151
height2 = mMoveView2.getMeasuredHeight();
5252
}
5353

54-
54+
private float lastY, currY;
5555
@Override
5656
public boolean dispatchTouchEvent(MotionEvent ev) {
5757
int[] location = new int[2];
@@ -66,32 +66,40 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
6666

6767
switch (ev.getAction()) {
6868
case MotionEvent.ACTION_UP:
69-
if(isScrollDown) break;
7069
//手指离开后恢复图片
7170
isScrolling = false;
71+
if(isScrollDown) break;
7272
replyImage();
7373
break;
7474
case MotionEvent.ACTION_MOVE:
75-
Log.e("xijingLog", "dispatchTouchEvent axes="+getScrollY()+" getY="+ev.getY()+" y="+y);
76-
if(y != 0) return super.dispatchTouchEvent(ev);
75+
if(y < 0) {
76+
//当非顶部的时候,下拉
77+
// Log.e("xijingLog", "dispatchTouchEvent 00 getY="+ev.getY()+" y="+y);
78+
return super.dispatchTouchEvent(ev);
79+
}
7780
isScrollDown = false;
81+
currY = ev.getY();
7882
if (!isScrolling) {
83+
// Log.e("xijingLog", "dispatchTouchEvent getScrollY()="+getScrollY());
7984
if (getScrollY() == 0) {
80-
firstPosition = ev.getY();// 滚动到顶部时记录位置,否则正常返回
85+
firstPosition = currY;// 滚动到顶部时记录位置,否则正常返回
86+
// Log.e("xijingLog", "dispatchTouchEvent 44 getY="+currY+" y="+firstPosition);
8187
} else {
88+
// Log.e("xijingLog", "dispatchTouchEvent 33 getY="+currY+" y="+y);
8289
break;
8390
}
8491
}
85-
int distance = (int) ((ev.getY() - firstPosition) * mScrollRate); // 滚动距离乘以一个系数
92+
int distance = (int) ((currY - firstPosition) * mScrollRate); // 滚动距离乘以一个系数
8693
if (distance < 0) { // 当前位置比记录位置要小,正常返回
94+
// Log.e("xijingLog", "dispatchTouchEvent 11 getY="+currY+" y="+y+" firstPosition="+firstPosition);
8795
isScrollDown = true;
8896
break;
8997
}
98+
// Log.e("xijingLog", "dispatchTouchEvent 22 getY="+currY+" y="+y);
9099
// 处理放大
91100
isScrolling = true;
92101
setZoom(distance);
93-
94-
return super.dispatchTouchEvent(ev);
102+
lastY = currY;
95103
}
96104
return super.dispatchTouchEvent(ev);
97105

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.