android - Make HorizontalScrollView hover ViewPager/Fragments -
is there way can create horizontalscrollview (slidingtablayout) hover viewpager , fragments instead of displaying them linearly?
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.zerohora.app.fragments.contentfragment"> <com.zerohora.app.widgets.slidingtablayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> <android.support.v4.view.viewpager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1" android:layout_gravity="top" /> </linearlayout>
already tried framelayout , relativelayout, , didn't work. swipe stops working after chang. changed margintop, viewpager on top of scrollview.
the thought here hide horizontalscrollview (slidingtab) whener users scrolls list in viewpager fragment.
thank you
i able find workaround it:
first bring view want on front end of others calling brintofront() method:
mslidingtablayout = (slidingtablayout) view.findviewbyid(r.id.sliding_tabs); mslidingtablayout.bringtofront();
then can place view wherever want. if want place on top after action bar, can following:
// viewport's heigth windowmanager wm = (windowmanager) getactivity().getsystemservice(context.window_service); display display = wm.getdefaultdisplay(); point size = new point(); display.getsize(size); int viewportheight = size.y; // actionbar's height typedvalue tv = new typedvalue(); int actionbarheight = 0; if (getactivity().gettheme().resolveattribute(android.r.attr.actionbarsize, tv, true)) { actionbarheight = typedvalue.complextodimensionpixelsize(tv.data, getresources().getdisplaymetrics()); } // status bar height int statusbarheight = 0; int resourceid = getresources().getidentifier("status_bar_height", "dimen", "android"); if (resourceid > 0) { statusbarheight = getresources().getdimensionpixelsize(resourceid); } // set tabs position linearlayout.layoutparams params = new linearlayout.layoutparams(relativelayout.layoutparams.match_parent, relativelayout.layoutparams.wrap_content); params.topmargin = -(viewportheight) + actionbarheight + statusbarheight; mslidingtablayout.setlayoutparams(params); //redraw display mslidingtablayout.invalidate(); mviewpager.invalidate();
android layout android-fragments android-viewpager android-tabs
No comments:
Post a Comment