android - Change header size while scrolling -


i've seen several posts discussing scrolling , header resizing , saw @mathieumaree's answer in post give me first idea how resize header while scrolling on listview.

so here implementation :

i have fragmentactivity viewpager containing 3 tabs expandablelistview.

here activity's layout :

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/root"     android:layout_width="fill_parent"     android:layout_height="wrap_content" >      <bla.bla.bla.views.headerficheequipe         android:id="@+id/header"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:gravity="center" >     </bla.bla.bla.views.headerficheequipe>      <relativelayout         android:id="@+id/tabview"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_alignparentbottom="true"         android:layout_below="@+id/header" >          <android.support.v4.view.viewpager             android:id="@+id/viewpager"             android:layout_width="match_parent"             android:layout_height="wrap_content" >              <android.support.v4.view.pagertabstrip                 android:id="@+id/titlestrip"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:textappearance="@style/pagertabstriptext" />         </android.support.v4.view.viewpager>     </relativelayout>  </relativelayout> 

first of all, set onscrolllistener on expandablelistview :

list.setonscrolllistener((cardactivity) getactivity()); 

then, i've implemented onscrolllistener on fragmentactivity :

@override public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) {     int totalsize = 0;     view v = view.getchildat(0);      if (v != null) {         if (elementsizes.size() > 0 && firstvisibleitem <= elementsizes.size()) {             (int = 0; < firstvisibleitem; ++i) {                 totalsize += elementsizes.get(i);             }             totalsize -= (v.gettop() - view.getpaddingtop());             if (totalsize > (maxheightheader - minheightheader))                 totalsize = maxheightheader - minheightheader;         } else {             totalsize = maxheightheader - minheightheader;         }         header.getlayoutparams().height = maxheightheader - totalsize;         header.requestlayout();     } }  @override public void onscrollstatechanged(abslistview view, int scrollstate) { } 

elementssize being list filled size of first elements of list. header reducing wished onscroll called way : when header reduced, list goes , if user keep finger on screen it's making android call onscroll again incorrect infos. header changing size lot of times during short period (jumping size want max height , max height wanted size) until i've arrived minimum size it's working great again.

i don't know if implementation correct right , if it's situation making not working or if i'm missing something. saw applications doing header resize while scrolling seem work differently : reduce header , after having header @ minimum size start scroll list.

how possible "block" scroll of list while header isn't @ minimum size? or there issue code resolved?

thanks in advance help

thomas


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -