scrollTo not working

2.1k views Asked by At

I am requesting help. Here is the code

    scrollView = (ScrollView)findViewById(R.id.scrollview4201);

    if (scrollview_f_check.contains("1"))
    {
        scrollView.scrollTo(0, +2000);

        scrollview_f_check = "0";
        SharedPreferences.Editor editor=mUserSettings.edit();
        editor.putString(USER_PREFERENCES_SCROLLVIEW4201, scrollview_f_check);
        editor.commit();
Toast.makeText(getApplicationContext(), "scrollview_f_check = " + String.valueOf(scrollview_f_check), Toast.LENGTH_SHORT).show();           
    }

I have verified using the toast that correct variable is passing through the if statement. So the issue lies completely with "scrollView.scrollTo(0, +2000);" line.

Why would this not work?

Part 2: I also tried to use the .getleft() and .getTop() of the exact TextView I wanted to use, but it always came back with 0 for both.

1

There are 1 answers

0
Lalit Mohan On

Also you can try using scrollTo() method in onWindowFocusChanged() method instead of onCreate().