简体   繁体   中英

TextView and ScrollingMovementMethod trouble

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM