How to get the scrollview total height = Scrollview.getScrollY() on Android -


i have on forums tricks not work me.

i have code:

scrollview = (scrollview)v.findviewbyid(r.id.scrollview);     scrollview.getviewtreeobserver().addonscrollchangedlistener(new onscrollchangedlistener() {          @override         public void onscrollchanged() {              log.d(mainactivity.tag, "scroll ch: "+scrollview.getscrolly()+"/"+scrollview.getchildat(0).getheight());         }     }); 

in layout.xml

<scrollview     android:id="@+id/scrollview"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignparentleft="true"     android:layout_alignparenttop="true" >      <linearlayout         android:id="@+id/principal"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:divider="@drawable/horiz"         android:orientation="vertical"         android:showdividers="end|middle" >     </linearlayout> </scrollview> 

when scroll down last getscrolly() smaller getchildat(0).getheight().

how can both having same total size ?

maybe change

layout_height="wrap_content" 

to

layout_height="match_parent" 

Comments