android - Item getting bigger when sliding ListView -


i implement list effect in android 1 displayed in ultravisual iphone app :

enter image description here

the similar effect can view on expo milano 2015 app in android.

i top item bigger when sliding down listview.

i have no idea how can done... animation on first item in current view?

if has example or clue achieve this, great!

thanks

well tried achieve effect , looked this:

enter image description here

first need start defining max , min font size. did this:

private final int max_fontsize=50; private final int min_fontsize=12; 

next need save screen total height. on oncreate save this:

    windowmanager wm = (windowmanager) getsystemservice(context.window_service);     display display = wm.getdefaultdisplay();     point size = new point();     display.getsize(size);     mscreenheight = size.y; 

then override listview onscroll event , this:

        @override         public void onscroll(abslistview view, int firstvisibleitem,int visibleitemcount, int totalitemcount) {             if(listview.getchildcount()>0)             for(int i=0;i<listview.getchildcount();i++)             {                 float font = math.min(math.max(max_fontsize - (float)(((max_fontsize-min_fontsize)/(mscreenheight*0.3)))*math.max(listview.getchildat(i).gettop(),0),min_fontsize),max_fontsize);                 ((textview)listview.getchildat(i)).settextsize(font);             }         } 

the 0.3 means @ 30% of screen minimum font size. can tweak value whatever want. remember listview.getchildat(i) return view inflate on adapter. in case it's simple textview, that's why it's safe cast textview. might need call findviewbyid textview.

you might need make textview centered looks prettier.

edit:

since op want change view's size (which should not used code) here hack can do. start changing min/max constants want (100 & 250). proceed create flag controls if listview scrolling or not. on onscrollstatechanged add line isscrolling= == scroll_state_touch_scroll || == scroll_state_fling; i second parameter of onscrollstatechanged. next change line if(listview.getchildcount()>0 && isscrolling). next step change view height. have change it's layoutparams.

listview.getchildat(i).setlayoutparams(new linearlayout.layoutparams(viewgroup.layoutparams.match_parent, math.round(font * getresources().getdisplaymetrics().density)));

remember is, said, simple hack. not, far, best solution this. since it's complex thing let's stick basics.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -