reset TextView scroll to top

Posted by JayAvon on Stack Overflow See other posts from Stack Overflow or by JayAvon
Published on 2011-01-14T03:48:54Z Indexed on 2011/01/14 3:53 UTC
Read the original article Hit count: 203

Filed under:
|
|

Okay well I apologize for how sloppy this code is, but I still cant figure out how to post a code tag on here correctly. So I am making an Android application (Java) and i have a scrolling text field. If the user scrolls a long row down and stays at the end when they click the next row and if it is short, it will be scrolled down on that element too even though it may be a 1 line(and non scrollable) row. I was wondering if there is any way I can call something to right after txtLvlInfo.setText to reset the x-scroll value to 0 or something so it is always reset to the top of the content, long or short. Thanks for any help with this and please let me know if I need to clarify more.

TextView txtLvlInfo = (TextView) findViewById(R.id.txtLevelInfo); txtLvlInfo.setMovementMethod(new ScrollingMovementMethod());

switch (v.getId()){ case R.id.row1: txtLvlInfo.setText("1: My text view is only two lines max and so I set it to scroll, if the user clicks row2 to load that text while having me scrolled down they have to click and pull to drag back down to the top of text view 2 row."); break; case R.id.row2: txtLvlInfo.setText("I only fill line 1 of the two."); break;

android:textColor="#052027"
android:text=""
android:id="@+id/txtLevelInfo"
android:scrollbars="vertical"
android:layout_alignParentLeft="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/minimizeBtn"
android:layout_marginRight="38dip">

© Stack Overflow or respective owner

Related posts about java

Related posts about android