当前位置: 首页>>代码示例>>Java>>正文


Java ScrollView.getHeight方法代码示例

本文整理汇总了Java中android.widget.ScrollView.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollView.getHeight方法的具体用法?Java ScrollView.getHeight怎么用?Java ScrollView.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ScrollView的用法示例。


在下文中一共展示了ScrollView.getHeight方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canScroll

import android.widget.ScrollView; //导入方法依赖的package包/类
static boolean canScroll(View view) {
    if (view instanceof ScrollView) {
        ScrollView scrollView = (ScrollView) view;
        View child = scrollView.getChildAt(0);
        if (child != null) {
            int childHeight = child.getHeight();
            return scrollView.getHeight() < childHeight + scrollView.getPaddingTop() + scrollView.getPaddingBottom();
        }
        return false;
    } else if (view instanceof RecyclerView) {
        RecyclerView recyclerView = (RecyclerView) view;
        int yOffset = recyclerView.computeVerticalScrollOffset();
        return yOffset != 0;
    }
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:Utils.java

示例2: getScrollPosition

import android.widget.ScrollView; //导入方法依赖的package包/类
@Nullable
@Override
public Point getScrollPosition(@Nullable ScrollView scrollView) {

    if (scrollView == null || scrollView.findViewById(view.getId()) == null) {
        // scrollview not set, or child is not part of the scrollview content: do not scroll.
        return null;
    }

    // get the top of the item relative to the ScrollView:
    Rect offsetViewBounds = new Rect();
    view.getDrawingRect(offsetViewBounds);
    scrollView.offsetDescendantRectToMyCoords(view, offsetViewBounds);
    int relativeTop = offsetViewBounds.top;

    // put the item in the middle of the screen:
    int scrollToY = relativeTop - (scrollView.getHeight() / 2);
    if (scrollToY < 0) {
        scrollToY = 0;
    }

    return new Point(scrollView.getScrollX(), scrollToY);
}
 
开发者ID:dimorinny,项目名称:show-case-card-view,代码行数:24,代码来源:ViewPosition.java

示例3: computeVerticalScrollRange

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
 * Copy From ScrollView (API Level >= 14)
 * <p>The scroll range of a scroll view is the overall height of all of its
 * children.</p>
 */
private int computeVerticalScrollRange(ScrollView scrollView) {
    final int count = scrollView.getChildCount();
    final int contentHeight = scrollView.getHeight() - scrollView.getPaddingBottom() - scrollView.getPaddingTop();
    if (count == 0) {
        return contentHeight;
    }

    int scrollRange = scrollView.getChildAt(0).getBottom();
    final int scrollY = scrollView.getScrollY();
    final int overScrollBottom = Math.max(0, scrollRange - contentHeight);
    if (scrollY < 0) {
        scrollRange -= scrollY;
    } else if (scrollY > overScrollBottom) {
        scrollRange += scrollY - overScrollBottom;
    }

    return scrollRange;
}
 
开发者ID:stytooldex,项目名称:pius1,代码行数:24,代码来源:SlideBottomPanel.java

示例4: scrollToBar

import android.widget.ScrollView; //导入方法依赖的package包/类
private void scrollToBar(int barIndex, int autoScrollAnimationTime) {
    ViewParent parentView = getParent();
    if (parentView instanceof ScrollView) {
        final ScrollView parentScrollView = (ScrollView) parentView;
        for (View view : views) {
            if (view instanceof SystemView
                    && view.isShown()) {
                SystemView systemView = (SystemView) view;
                if (systemView.containsBar(barIndex)) {
                    int scroll_max = getBottom() - parentScrollView.getHeight();
                    int scroll_min = 0;
                    float windowHeight = parentScrollView.getHeight();
                    float windowPlayingCentre = kWindowPlayingCentreFractionFromTop * windowHeight;
                    float sysFrac = systemView.fractionalScroll(barIndex);
                    float playingCentre = view.getTop() + view.getHeight() * sysFrac;
                    float scroll_y = playingCentre - windowPlayingCentre;

                    if (scroll_y < scroll_min)
                        scroll_y = scroll_min;
                    else if (scroll_y > scroll_max)
                        scroll_y = scroll_max;
                    slowSmoothScrollTo(parentScrollView, (int) scroll_y, autoScrollAnimationTime);
                }
            }
        }
    }
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:28,代码来源:SeeScoreView.java

示例5: canChildScrollDown

import android.widget.ScrollView; //导入方法依赖的package包/类
public static boolean canChildScrollDown(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            if (scrollView.getChildCount() == 0) {
                return false;
            } else {
                return scrollView.getScrollY() < scrollView.getChildAt(0).getHeight() - scrollView.getHeight();
            }
        } else {
            return false;
        }
    } else {
        return view.canScrollVertically(1);
    }
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:22,代码来源:PtrDefaultHandler2.java

示例6: canChildPullUp

import android.widget.ScrollView; //导入方法依赖的package包/类
public boolean canChildPullUp() {
    if (child instanceof AbsListView) {
        AbsListView absListView = (AbsListView) child;
        return canScrollVertically(child, 1)
                || absListView.getLastVisiblePosition() != mTotalItemCount - 1;
    } else if (child instanceof WebView) {
        WebView webview = (WebView) child;
        if (webview instanceof XWebView) {
            return !((XWebView) webview).isBottom();
        } else {
            float left = webview.getContentHeight() * webview.getScale();
            int right = webview.getHeight() + webview.getScrollY();
            return left != right;
        }
    } else if (child instanceof ScrollView) {
        ScrollView scrollView = (ScrollView) child;
        View childView = scrollView.getChildAt(0);
        if (childView != null) {
            return canScrollVertically(child, 1)
                    || scrollView.getScrollY() < childView.getHeight() - scrollView.getHeight();
        }
    } else {
        return canScrollVertically(child, 1);
    }
    return true;
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:27,代码来源:XRefreshContentView.java

示例7: scrollViewCanScrollVertically

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
 *  Copy From ScrollView (API Level >= 14)
 * @param direction Negative to check scrolling up, positive to check
 *                  scrolling down.
 *   @return true if the scrollView can be scrolled in the specified direction,
 *         false otherwise
 */
private  boolean scrollViewCanScrollVertically(ScrollView scrollView,int direction) {
    final int offset = Math.max(0, scrollView.getScrollY());
    final int range = computeVerticalScrollRange(scrollView) - scrollView.getHeight();
    if (range == 0) return false;
    if (direction < 0) { //scroll up
        return offset > 0;
    } else {//scroll down
        return offset < range - 1;
    }
}
 
开发者ID:stytooldex,项目名称:pius1,代码行数:18,代码来源:SlideBottomPanel.java

示例8: isAtBottom

import android.widget.ScrollView; //导入方法依赖的package包/类
private boolean isAtBottom() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        return !ViewCompat.canScrollVertically(mTarget, 1);
    } else {
        if (mTarget instanceof RecyclerView) {
            return SuperSwipeHelper.isAtBottom((RecyclerView) mTarget);
        } else if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            int count = absListView.getAdapter().getCount();
            int firstPos = absListView.getFirstVisiblePosition();
            if (firstPos == 0
                    && absListView.getChildAt(0).getTop() >= absListView
                    .getPaddingTop()) {
                return false;
            }
            int lastPos = absListView.getLastVisiblePosition();
            if (lastPos > 0 && count > 0 && lastPos == count - 1) {
                return true;
            }
            return false;
        } else if (mTarget instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) mTarget;
            View view = (View) scrollView
                    .getChildAt(scrollView.getChildCount() - 1);
            if (view != null) {
                int diff = (view.getBottom() - (scrollView.getHeight() + scrollView
                        .getScrollY()));
                if (diff == 0) {
                    return true;
                }
            }
        }
        return false;
    }
}
 
开发者ID:FreeSunny,项目名称:Amazing,代码行数:36,代码来源:SuperSwipeRefreshLayout.java

示例9: svPullUpIntercept

import android.widget.ScrollView; //导入方法依赖的package包/类
public boolean svPullUpIntercept(View child) {
    boolean intercept = false;
    ScrollView scrollView = (ScrollView) child;
    View scrollChild = scrollView.getChildAt(0);

    if (scrollView.getScrollY() >= (scrollChild.getHeight() - scrollView.getHeight())) {
        intercept = true;
    }
    return intercept;
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:11,代码来源:InterceptLayout.java

示例10: canChildScrollUp

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
     * @return Whether it is possible for the child view of this layout to
     * scroll up. Override this if the child view is a custom view.
     */
    public boolean canChildScrollUp(float f) {
        boolean flag = false;

        if (!mRefreshing) {
            if (mTarget instanceof ScrollView) {

                final ScrollView scrollView = (ScrollView) mTarget;
                int scrollY = scrollView.getScrollY();
                int height = scrollView.getHeight();
                int scrollViewMeasuredHeight = scrollView.getChildAt(0).getMeasuredHeight();

//                Log.i("Test", "canChildScrollUp scrollY = " + scrollY + "| height = " + height + " | scrollViewMeasuredHeight = " + scrollViewMeasuredHeight);

                if (enabledPullDown && scrollY == 0 && f > 0) {
                    //滑动到了顶端 view.getScrollY()="+scrollY);
                    //Log.i("Test", "canChildScrollUp:" + f);
                    flag = false;
                } else if (enabledPullUp && (scrollY + height) >= scrollViewMeasuredHeight && f < 0) {
                    //滑动到了底部 scrollY="+scrollY);
                    //Log.i("Test", "canChildScrollUp:" + f);
                    flag = false;
                } else {
                    flag = true;
                }
            }
        } else {
            flag = true;
        }
        return flag;
    }
 
开发者ID:React-Native-Library,项目名称:react-native-pull-up-down-refresh,代码行数:35,代码来源:RCTSwipeRefreshLayout.java

示例11: scrollOnDrag

import android.widget.ScrollView; //导入方法依赖的package包/类
private void scrollOnDrag(View view, DragEvent event, ScrollView scrollView) {
    float ty = view.getTop() + event.getY();

    if (isAncestor(scrollView, view)) {

        int thresh = scrollView.getHeight() / 6;

        if (ty < scrollView.getScrollY() + thresh) {
            scrollView.smoothScrollBy(0, -10);
        } else if (ty > scrollView.getScrollY() + scrollView.getHeight() - thresh) {
            scrollView.smoothScrollBy(0, 10);
        }
    }
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:15,代码来源:MainActivity.java

示例12: canChildScrollDown

import android.widget.ScrollView; //导入方法依赖的package包/类
public static boolean canChildScrollDown(View view) {
    if (view instanceof AbsListView) {
        final AbsListView absListView = (AbsListView) view;
        if (Build.VERSION.SDK_INT < 14) {
            return absListView.getChildCount() == 0
                    || absListView.getAdapter() == null
                    || (absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getAdapter().getCount() - 1)
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom()
                    > absListView.getHeight() - absListView.getPaddingBottom());
        } else {
            if (Build.VERSION.SDK_INT < 26)
                return absListView.getChildCount() == 0 ||
                        ViewCompat.canScrollVertically(view, 1);
            else
                return absListView.getChildCount() == 0 ||
                        view.canScrollVertically(1);
        }
    } else if (view instanceof ScrollView) {
        final ScrollView scrollView = (ScrollView) view;
        if (Build.VERSION.SDK_INT < 14) {
            return scrollView.getChildCount() == 0
                    || (scrollView.getChildCount() != 0
                    && scrollView.getScrollY() < scrollView.getChildAt(0).getHeight()
                    - scrollView.getHeight());
        } else {
            if (Build.VERSION.SDK_INT < 26)
                return scrollView.getChildCount() == 0 ||
                        ViewCompat.canScrollVertically(view, 1);
            else
                return scrollView.getChildCount() == 0 ||
                        view.canScrollVertically(1);
        }
    } else {
        try {
            if (view instanceof RecyclerView) {
                final RecyclerView recyclerView = (RecyclerView) view;
                if (Build.VERSION.SDK_INT < 26)
                    return recyclerView.getChildCount() == 0 ||
                            ViewCompat.canScrollVertically(view, 1);
                else
                    return recyclerView.getChildCount() == 0 ||
                            view.canScrollVertically(1);
            }
        } catch (NoClassDefFoundError e) {
            e.printStackTrace();
        }
        if (Build.VERSION.SDK_INT < 26)
            return ViewCompat.canScrollVertically(view, 1);
        else
            return view.canScrollVertically(1);
    }
}
 
开发者ID:dkzwm,项目名称:SmoothRefreshLayout,代码行数:54,代码来源:ScrollCompat.java


注:本文中的android.widget.ScrollView.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。