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.

有帮助吗?

解决方案

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);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top