문제

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