android.support.v4.widget.NestedScrollView.getScrollY()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中android.support.v4.widget.NestedScrollView.getScrollY()方法的一些代码示例,展示了NestedScrollView.getScrollY()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NestedScrollView.getScrollY()方法的具体详情如下:
包路径:android.support.v4.widget.NestedScrollView
类名称:NestedScrollView
方法名:getScrollY

NestedScrollView.getScrollY介绍

暂无

代码示例

代码示例来源:origin: iMeiji/Toutiao

scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> {
  View view1 = scrollView.getChildAt(scrollView.getChildCount() - 1);
  int diff = (view1.getBottom() - (scrollView.getHeight() + scrollView.getScrollY()));
  if (diff == 0) {
    canLoadMore = false;

代码示例来源:origin: hidroh/materialistic

@Synthetic
void setFullscreen(boolean isFullscreen) {
  if (getView() == null) {
    return;
  }
  mFullscreen = isFullscreen;
  mControls.setVisibility(isFullscreen ? VISIBLE : View.GONE);
  AppUtils.toggleWebViewZoom(mWebView.getSettings(), isFullscreen);
  ViewGroup.LayoutParams params = mWebView.getLayoutParams();
  if (isFullscreen) {
    mScrollView.removeView(mScrollViewContent);
    mWebView.scrollTo(mScrollView.getScrollX(), mScrollView.getScrollY());
    mFullscreenView.addView(mScrollViewContent);
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;
  } else {
    reset();
    // We'll zoom out until it returns false, which means it has min zoom level.
    // It's quite dangerous piece of code - potentially could lead to infinite loop,
    // so let's add some reasonable limit just in case
    int i = 0;
    while (mWebView.zoomOut() && i < 30) {
     i++;
    }
    mFullscreenView.removeView(mScrollViewContent);
    mScrollView.addView(mScrollViewContent);
    mScrollView.post(() -> mScrollView.scrollTo(mWebView.getScrollX(), mWebView.getScrollY()));
    params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
  }
  mWebView.setLayoutParams(params);
}

代码示例来源:origin: nuptboyzhb/SuperSwipeRefreshLayout

View view = (View) nestedScrollView.getChildAt(nestedScrollView.getChildCount() - 1);
if (view != null) {
  int diff = (view.getBottom() - (nestedScrollView.getHeight() + nestedScrollView.getScrollY()));
  if (diff == 0) {
    return true;

代码示例来源:origin: SalmanZach/SmartStickyHeader

@Override
  public void run() {
    onScroll(-mScrollView.getScrollY());
  }
});

代码示例来源:origin: TongmingWu/Manga

@Override
  public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
    int scrollPixel = CommonUtil.getScreenHeight(getApplicationContext()) / 3;
    if (v.getScrollY() > 0 && v.getScrollY() < scrollPixel) {
      //alpha值超过255的效果跟0一样
      //426,640,853
      int alpha = v.getScrollY() / (scrollPixel / 280);
      appbar.setBackgroundColor(Color.argb(alpha >= 255 ? 255 : alpha, 255, 150, 12));
    }
  }
});

代码示例来源:origin: SalmanZach/SmartStickyHeader

@Override
  public void onScrollChanged() {
    onScroll(-mScrollView.getScrollY());
  }
});

代码示例来源:origin: adgvcxz/Dribbble-MVVM

@InverseBindingAdapter(attribute = "scrollY", event = "scrollYAttrChanged")
public static int getScrollY(NestedScrollView nestedScrollView) {
  return nestedScrollView.getScrollY();
}

代码示例来源:origin: adgvcxz/Dribbble-MVVM

@BindingAdapter({"scrollY"})
  public static void setScrollY(NestedScrollView nestedScrollView, int scrollY) {
    if (scrollY != nestedScrollView.getScrollY()) {
      nestedScrollView.setScrollY(scrollY);
    }
  }
}

代码示例来源:origin: dom4j1/Red

@Override
  public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
    View view = mScrollView.getChildAt(mScrollView.getChildCount() - 1);
    int d = view.getBottom();
    d -= (mScrollView.getHeight() + mScrollView.getScrollY());
    if (d == 0) {
      showSnakerbar();
    }
  }
}

代码示例来源:origin: ywwynm/EverythingDone

private void updateBottomBarShadow() {
  Rect windowRect = new Rect();
  getWindow().getDecorView().getWindowVisibleDisplayFrame(windowRect);
  final View bottomBarShadow = f(R.id.bottom_bar_shadow);
  final int bottomBarHeight = (int) (screenDensity * 56);
  final int statusBarHeight = DisplayUtil.getStatusbarHeight(this);
  int scrollY = mScrollView.getScrollY();
  int childHeight = mScrollView.getChildAt(0).getHeight();
  int marginTop = statusBarHeight;
  if (mRvImageAttachment.getVisibility() != View.VISIBLE) {
    marginTop += bottomBarHeight;
  } else if (DeviceUtil.hasKitKatApi()) {
    marginTop -= statusBarHeight;
  }
  float aY = childHeight - windowRect.bottom
      + bottomBarHeight + marginTop - screenDensity * 40;
  float tY = aY + screenDensity * 24;
  if (scrollY <= aY) {
    bottomBarShadow.setAlpha(1.0f);
  } else if (scrollY >= tY) {
    bottomBarShadow.setAlpha(0);
  } else {
    float progress = tY - scrollY;
    bottomBarShadow.setAlpha(progress / (tY - aY));
  }
}

代码示例来源:origin: shaopx/CoordinatorLayoutExample

private boolean reachBottom(View target) {
  if (target instanceof NestedScrollView) {
    NestedScrollView nestedScrollView = (NestedScrollView) target;
    int scrollY = nestedScrollView.getScrollY();
    View onlyChild = nestedScrollView.getChildAt(0);
    if (onlyChild.getHeight() <= scrollY + nestedScrollView.getHeight()) {
      return true;
    }
  } else if (target instanceof RecyclerView) {
    RecyclerView recyclerView = (RecyclerView) target;
    if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset()
        >= recyclerView.computeVerticalScrollRange()) {
      return true;
    }
  }
  return false;
}

相关文章