Question

I'm currently doing this to make my TextView scrollable:

myTextView.setMovementMethod(new ScrollingMovementMethod());

What I want is to be able to, on create, have the visible portion of my TextView be a certain line of text that I choose.

As it is right now, it simply shows the very top of my text in the TextView, allowing me to scroll downwards.

Is there no way for me to be able to set where I want the scroll to start at? I've searched endlessly but to no avail. Thanks.

Was it helpful?

Solution

This can be helpful try it.

    final int amount = yourTextView.getLayout().getLineTop(yourTextView.getLineCount()) - yourValue;
    // if there is no need to scroll, amount will be <=0
    if (amount > 0)
        yourTextView.scrollTo(0, amount);
    else
        yourTextView.scrollTo(0, 0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top