Elad Benda
Elad Benda

Reputation: 36654

how much can a scrollView scroll?

I have a layout with a scrollView inside it.

How can I calculate what's the possible scroll size?

I would think:

(scroll's content desired height) - window.height = (invisible content height)

But how do I get the scroll's content actual desired height?

I can get the scrollView height, which is not what I need.

I saw this post, but I don't get the calaulation.

int diff = (view.getBottom() - (getHeight() + getScrollY()));// Calculate

Upvotes: 3

Views: 236

Answers (1)

Mazhar Iqbal
Mazhar Iqbal

Reputation: 999

// you can do it by the following two attributes in xml in scrollview it will scroll 
//accroding to the child views it contain
     android:animateLayoutChanges="true"
     android:orientation="vertical"

//here is the full example 
 <ScrollView
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_marginBottom="50dp"
 android:animateLayoutChanges="true"
 android:orientation="vertical"
 tools:context=".fragments.frag1"
 >
  <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bgsecond"
    android:layout_marginBottom="40dp"
     >
  </RelativeLayout>
 </ScrollView>

Upvotes: 0

Related Questions