android.widget.ScrollView.dispatchDraw()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(148)

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

ScrollView.dispatchDraw介绍

暂无

代码示例

代码示例来源:origin: ZieIony/Carbon

@Override
protected void dispatchDraw(@NonNull Canvas canvas) {
  super.dispatchDraw(canvas);
  if (topGlow != null) {
    final int scrollY = getScrollY();
    if (!topGlow.isFinished()) {
      final int restoreCount = canvas.save();
      final int width = getWidth() - getPaddingLeft() - getPaddingRight();
      canvas.translate(getPaddingLeft(), Math.min(0, scrollY));
      topGlow.setSize(width, getHeight());
      if (topGlow.draw(canvas))
        invalidate();
      canvas.restoreToCount(restoreCount);
    }
    if (!bottomGlow.isFinished()) {
      final int restoreCount = canvas.save();
      final int width = getWidth() - getPaddingLeft() - getPaddingRight();
      final int height = getHeight();
      canvas.translate(-width + getPaddingLeft(),
          Math.max(computeVerticalScrollRange() - getHeight(), scrollY) + height);
      canvas.rotate(180, width, 0);
      bottomGlow.setSize(width, height);
      if (bottomGlow.draw(canvas))
        invalidate();
      canvas.restoreToCount(restoreCount);
    }
  }
}

代码示例来源:origin: weexteam/weex-hackernews

@Override
protected void dispatchDraw(Canvas canvas) {
 super.dispatchDraw(canvas);
 if (mCurrentStickyView != null) {
  canvas.save();
  mCurrentStickyView.getLocationOnScreen(mStickyP);
  int realOffset = (mStickyOffset <= 0 ? mStickyOffset : 0);
  canvas.translate(mStickyP[0], getScrollY() + realOffset);
  canvas.clipRect(0, realOffset, mCurrentStickyView.getWidth(),
          mCurrentStickyView.getHeight());
  mCurrentStickyView.draw(canvas);
  canvas.restore();
 }
}

代码示例来源:origin: colinNaive/RecyclerViewScrollView

@Override
protected void dispatchDraw(Canvas canvas) {
  super.dispatchDraw(canvas);
  if(getScrollY() >= view.getTop()){
    fixHead();
    canvas.save();
    canvas.translate(0,getScrollY());
    canvas.clipRect(0,0,view.getWidth(),view.getHeight());
    view.draw(canvas);
    canvas.restore();
  }else {
    resetHead();
  }
}

代码示例来源:origin: colinNaive/RecyclerViewScrollView

@Override
protected void dispatchDraw(Canvas canvas) {
  super.dispatchDraw(canvas);
  if (getScrollY() >= fixView.getTop()) {
    fix();
  } else {
    dismiss();
  }
}

代码示例来源:origin: moz1q1/WalleLibrary

@Override
protected void dispatchDraw(Canvas canvas) {
  super.dispatchDraw(canvas);
  if (currentlyStickingView != null) {
    canvas.save();
    canvas.translate(getPaddingLeft() + stickyViewLeftOffset, getScrollY() + stickyViewTopOffset + (clippingToPadding ? getPaddingTop() : 0));
    canvas.clipRect(0, (clippingToPadding ? -stickyViewTopOffset : 0),
        getWidth() - stickyViewLeftOffset,
        currentlyStickingView.getHeight() + mShadowHeight + 1);
    if (mShadowDrawable != null) {
      int left = 0;
      int right = currentlyStickingView.getWidth();
      int top = currentlyStickingView.getHeight();
      int bottom = currentlyStickingView.getHeight() + mShadowHeight;
      mShadowDrawable.setBounds(left, top, right, bottom);
      mShadowDrawable.draw(canvas);
    }
    canvas.clipRect(0, (clippingToPadding ? -stickyViewTopOffset : 0), getWidth(), currentlyStickingView.getHeight());
    if (getStringTagForView(currentlyStickingView).contains(FLAG_HASTRANSPARANCY)) {
      showView(currentlyStickingView);
      currentlyStickingView.draw(canvas);
      hideView(currentlyStickingView);
    } else {
      currentlyStickingView.draw(canvas);
    }
    canvas.restore();
  }
}

代码示例来源:origin: derry/delion

@Override
  protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);
    if (mFadingShadow != null) {
      setVerticalFadingEdgeEnabled(true);
      float shadowStrength = getBottomFadingEdgeStrength();
      float shadowHeight = getVerticalFadingEdgeLength();
      setVerticalFadingEdgeEnabled(false);
      mFadingShadow.drawShadow(this, canvas, FadingShadow.POSITION_BOTTOM,
          shadowHeight, shadowStrength);
    }
  }
}

代码示例来源:origin: derry/delion

@Override
protected void dispatchDraw(Canvas canvas) {
  super.dispatchDraw(canvas);
  setVerticalFadingEdgeEnabled(true);
  float topShadowStrength = getTopFadingEdgeStrength();
  float bottomShadowStrength = getBottomFadingEdgeStrength();
  float shadowHeight = getVerticalFadingEdgeLength();
  setVerticalFadingEdgeEnabled(false);
  if (mDrawTopShadow) {
    mFadingShadow.drawShadow(this, canvas, FadingShadow.POSITION_TOP,
        shadowHeight, topShadowStrength);
  }
  if (mDrawBottomShadow) {
    mFadingShadow.drawShadow(this, canvas, FadingShadow.POSITION_BOTTOM,
        shadowHeight, bottomShadowStrength);
  }
}

相关文章

ScrollView类方法