Code example for Layout

Methods: getLineCountgetLineTopscrollTo

0
    protected boolean scrollPageDown(TextView widget, Spannable buffer) {
        final Layout layout = widget.getLayout();
        final int innerHeight = getInnerHeight(widget);
        final int bottom = widget.getScrollY() + innerHeight + innerHeight;
        int bottomLine = layout.getLineForVertical(bottom);
        if (bottomLine <= layout.getLineCount() - 1) {
            Touch.scrollTo(widget, layout, widget.getScrollX(),
                    layout.getLineTop(bottomLine + 1) - innerHeight);
            return true; 
        } 
        return false; 
    } 
 
    /** 
     * Performs a scroll to top action. 
     * Scrolls to the top of the document. 
     * 
     * @param widget The text view. 
     * @param buffer The text buffer. 
     * @return True if the event was handled. 
Experience pair programming with AI  Get Codota for Java