android - Scrolling GridView only on Button Click -


i want achieve following layout -

required layout

in layout, want show available items user. pressing right arrow show next 6 available items. should happen via horizontal scrolling type motion. since items can many, want use gridview because of recycling optimisation. optimisation necessary because every item linear layout in itself.

now, can't use gridview because want show next 6 items using arrows only. also, if happens in smooth scrolling type motion.

can make tweak gridview can use arrows scroll gridview show next 6 items or there other viewgroup available achieve along recycling optimisation.

this example listview can refer gridview also.

for smoothscroll scroll duration:

getlistview().smoothscrolltopositionfromtop(position,offset,duration); 

parameters position -> position scroll offset ---->desired distance in pixels of position top of view when scrolling finished duration-> number of milliseconds use scroll note: api 11.

listview quite lengthy , alphabet scroller. found same function can take other parameters :)

to position current selection:

int h1 = mlistview.getheight(); int h2 = v.getheight();  mlistview.smoothscrolltopositionfromtop(position, h1/2 - h2/2, duration);  

or

you can use recyclerview : have make use of layoutmanager that. follow below steps.

1). first of all, declare layoutmanager in activity/fragment. example, have taken linearlayoutmanager

private linearlayoutmanager mlinearlayoutmanager; 

2). initialise linearlayoutmanager , set recyclerview

mlinearlayoutmanager = new linearlayoutmanager(this); recyclerview.setlayoutmanager(mlinearlayoutmanager); 

3). on button onclick, scroll bottom of recyclerview.

mlinearlayoutmanager.scrolltoposition(yourlist.size() - 1); // yourlist arraylist passing recyclerview adapter.

hope help..!!


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -