}
x += getScrollX();
y += getScrollY();
- if (isVerticalScrollBarEnabled() && !isVerticalScrollBarHidden()) {
+ final boolean canScrollVertically =
+ computeVerticalScrollRange() > computeVerticalScrollExtent();
+ if (isVerticalScrollBarEnabled() && !isVerticalScrollBarHidden() && canScrollVertically) {
final Rect touchBounds = mScrollCache.mScrollBarTouchBounds;
getVerticalScrollBarBounds(null, touchBounds);
if (touchBounds.contains((int) x, (int) y)) {
return true;
}
}
- if (isHorizontalScrollBarEnabled()) {
+ final boolean canScrollHorizontally =
+ computeHorizontalScrollRange() > computeHorizontalScrollExtent();
+ if (isHorizontalScrollBarEnabled() && canScrollHorizontally) {
final Rect touchBounds = mScrollCache.mScrollBarTouchBounds;
getHorizontalScrollBarBounds(null, touchBounds);
if (touchBounds.contains((int) x, (int) y)) {
}
private boolean isOnVerticalScrollbarThumb(float x, float y) {
- if (mScrollCache == null) {
+ if (mScrollCache == null || !isVerticalScrollBarEnabled() || isVerticalScrollBarHidden()) {
return false;
}
- if (isVerticalScrollBarEnabled() && !isVerticalScrollBarHidden()) {
+ final int range = computeVerticalScrollRange();
+ final int extent = computeVerticalScrollExtent();
+ if (range > extent) {
x += getScrollX();
y += getScrollY();
final Rect bounds = mScrollCache.mScrollBarBounds;
final Rect touchBounds = mScrollCache.mScrollBarTouchBounds;
getVerticalScrollBarBounds(bounds, touchBounds);
- final int range = computeVerticalScrollRange();
final int offset = computeVerticalScrollOffset();
- final int extent = computeVerticalScrollExtent();
final int thumbLength = ScrollBarUtils.getThumbLength(bounds.height(), bounds.width(),
extent, range);
final int thumbOffset = ScrollBarUtils.getThumbOffset(bounds.height(), thumbLength,
}
private boolean isOnHorizontalScrollbarThumb(float x, float y) {
- if (mScrollCache == null) {
+ if (mScrollCache == null || !isHorizontalScrollBarEnabled()) {
return false;
}
- if (isHorizontalScrollBarEnabled()) {
+ final int range = computeHorizontalScrollRange();
+ final int extent = computeHorizontalScrollExtent();
+ if (range > extent) {
x += getScrollX();
y += getScrollY();
final Rect bounds = mScrollCache.mScrollBarBounds;
final Rect touchBounds = mScrollCache.mScrollBarTouchBounds;
getHorizontalScrollBarBounds(bounds, touchBounds);
- final int range = computeHorizontalScrollRange();
final int offset = computeHorizontalScrollOffset();
- final int extent = computeHorizontalScrollExtent();
+
final int thumbLength = ScrollBarUtils.getThumbLength(bounds.width(), bounds.height(),
extent, range);
final int thumbOffset = ScrollBarUtils.getThumbOffset(bounds.width(), thumbLength,