Code example for Layout

Methods: getLineTop, scrollTo

0
     */ 
    protected boolean scrollUp(TextView widget, Spannable buffer, int amount) {
        final Layout layout = widget.getLayout();
        final int top = widget.getScrollY();
        int topLine = layout.getLineForVertical(top);
        if (layout.getLineTop(topLine) == top) {
            // If the top line is partially visible, bring it all the way 
            // into view; otherwise, bring the previous line into view. 
            topLine -= 1;
        } 
        if (topLine >= 0) {
            topLine = Math.max(topLine - amount + 1, 0);
            Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop(topLine));
            return true; 
        } 
        return false; 
    } 
 
    /** 
     * Performs a scroll down action. 
     * Scrolls down by the specified number of lines.