How do I get the amount of pixels which a user has scrolled in a scroll view. I have a scroll view which contains lot of texts. I also have a button at bottom of the screen. What I want is to change text on the button to the amount of scrolling done in the scroll view.
this is my scroll view:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollverbal"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/verbalintro"
android:textSize="15sp"
/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/verqstns"
android:textSize="15sp"
/>
</LinearLayout>
</ScrollView>
and my button is
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="15"
android:background="@android:color/transparent"
android:textSize="20sp"
android:textStyle="bold"
android:drawablePadding="-5sp"
android:paddingLeft="10sp"
android:drawableLeft="@drawable/tick"
/>
I read that it can be done using getScrollY()
method. but don't know how to use it programatically.