android - How to make whole screen scrollable in Viewpager Fragment -
i have grid view , listview(including pagination) in scrollview.
this resulting individual scroll need whole screen scrollable pagination. tried use nestedlistview & expandableheightlistview not working properly.
any suggestion grateful.
enter codxml:: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.swiperefreshlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/swipecontainer" android:layout_width="match_parent" android:layout_height="match_parent"> <scrollview android:id="@+id/scrollview" android:layout_width="match_parent" android:layout_height="wrap_content" android:cliptopadding="false" android:fillviewport="true" android:paddingbottom="75dp"> <relativelayout android:id="@+id/root_rl" android:layout_width="match_parent" android:layout_height="wrap_content" android:descendantfocusability="beforedescendants" android:focusable="true" android:focusableintouchmode="true"> <textview android:id="@+id/all_tpcs_heading" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/bg_horizantal_magzine_listview" android:padding="@dimen/ten_dp" android:text="all topics" android:textallcaps="true" android:textsize="14sp" /> <com.healthyliving.live.utils.expandableheightgridview android:id="@+id/topicsgrid" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/all_tpcs_heading" android:layout_margintop="@dimen/six_dp" android:clipchildren="true" android:gravity="center" android:horizontalspacing="@dimen/six_dp" android:isscrollcontainer="false" android:numcolumns="2" android:stretchmode="none" android:verticalspacing="@dimen/six_dp" /> <textview android:id="@+id/rcnt_artcls_heading" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/topicsgrid" android:layout_margintop="@dimen/six_dp" android:paddingbottom="@dimen/ten_dp" android:paddingleft="@dimen/ten_dp" android:paddingright="@dimen/ten_dp" android:paddingtop="@dimen/sixteen_dp" android:text="recent articles" android:textallcaps="true" android:textsize="14sp" /> <listview android:id="@+id/recent_articles_listview" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_below="@+id/rcnt_artcls_heading" android:dividerheight="@dimen/list_view_divider" /> <progressbar android:layout_centerhorizontal="true" android:layout_alignparentbottom="true" android:id="@+id/load_progreebar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminatedrawable="@drawable/my_progress_indeterminate" android:visibility="gone" /> </relativelayout> </scrollview>
fragment::
recentarticleadapter = new explorerecentartilcesadapter(getactivity(), featuredarticles); mrecentarticles.setadapter(recentarticleadapter);
use below given custom list , grid view instead of default listview
, gridview
in layout xml file.
custom listview :-
public class customlistview extends listview { public customlistview(context context, attributeset attrs) { super(context, attrs); } public customlistview(context context) { super(context); } public customlistview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); } @override public void onmeasure(int widthmeasurespec, int heightmeasurespec) { int expandspec = measurespec.makemeasurespec(integer.max_value >> 2, measurespec.at_most); super.onmeasure(widthmeasurespec, expandspec); } }
custom gridview :-
public class customgridview extends gridview { public customgridview(context context, attributeset attrs) { super(context, attrs); } public customgridview(context context) { super(context); } public customgridview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); } @override public void onmeasure(int widthmeasurespec, int heightmeasurespec) { int expandspec = measurespec.makemeasurespec(integer.max_value >> 2, measurespec.at_most); super.onmeasure(widthmeasurespec, expandspec); } }
in approach, if find difficulties in vertical scroll , horizontal swipe(as have view pager) use below custom scrollview
class instead of default scroll view in layout xml file.
public class verticalscrollview extends scrollview { private float xdistance, ydistance, lastx, lasty; public verticalscrollview(context context, attributeset attrs) { super(context, attrs); } @override public boolean onintercepttouchevent(motionevent ev) { switch (ev.getaction()) { case motionevent.action_down: xdistance = ydistance = 0f; lastx = ev.getx(); lasty = ev.gety(); break; case motionevent.action_move: final float curx = ev.getx(); final float cury = ev.gety(); xdistance += math.abs(curx - lastx); ydistance += math.abs(cury - lasty); lastx = curx; lasty = cury; if(xdistance > ydistance) return false; } return super.onintercepttouchevent(ev); } }
use these custom view classes in same way used com.healthyliving.live.utils.expandableheightgridview
custom view in current implementation. hope answer you.
Comments
Post a Comment