Closed vibin closed 9 years ago
Hello. I'm trying to implement Toolbar hiding in Viewpager with Tabs and Listview. In the samples (https://github.com/ksoichiro/Android-ObservableScrollView/blob/master/samples/res/layout/activity_viewpagertab.xml#L28) the layout for main activity adds some padding (@dimen/tab_height) to FrameLayout wrapping ViewPager so that it can be visible below the overlaying Toolbar.
Now, after implementing ObservableScrollViewCallbacks, the Header (Toolbar+Tabs) will translateY and leave empty space below the Tabs. I tried changing the padding of the wrapping FrameLayout in onScrollChanged(), but it starts flickering.
Check these two screenshots: http://cl.ly/aaoD and http://cl.ly/abFz Main Activity layout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:fitsSystemWindows="true"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/pagerFrame" android:paddingTop="104dp"> <!-- toolbar + tabs = 56dp + 48dp--> <android.support.v4.view.ViewPager xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.vibin.billy.activity.MainActivity" /> </FrameLayout> <LinearLayout android:id="@+id/header" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:elevation="6dp" android:orientation="vertical"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:minHeight="?attr/actionBarSize" /> <com.astuetz.PagerSlidingTabStrip android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="48dp" android:background="@color/billy" android:textSize="14sp" app:pstsDividerColor="@android:color/transparent" app:pstsIndicatorColor="#fff" app:pstsIndicatorHeight="2dp" app:pstsTabBackground="@android:color/transparent" app:pstsUnderlineHeight="0dp" /> </LinearLayout> </FrameLayout>
Fragment layout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/frag" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:id="@+id/spinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="10dp" android:gravity="center" android:visibility="gone" tools:visibility="visible"> <ProgressBar style="?android:attr/progressBarStyleLarge" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="center" android:visibility="visible" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/loadingtext" android:gravity="center" android:fontFamily="sans-serif-condensed" android:textSize="24sp" android:visibility="visible" android:layout_marginLeft="5dp" /> </LinearLayout> <!-- SwipeRefreshLayout should have only one child view --> <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipe_container" android:layout_width="match_parent" android:layout_height="match_parent"> <com.github.ksoichiro.android.observablescrollview.ObservableListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@android:color/transparent" android:dividerHeight="0.0dp" android:visibility="invisible" tools:visibility="visible" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingTop="1dp" android:paddingBottom="2dp" android:clipToPadding="false" /> </android.support.v4.widget.SwipeRefreshLayout> </FrameLayout>
You could use the method that add header to the ObservableListView instead of setting margins and paddings!
ObservableListView
@f4cker that worked, thanks!
Hello. I'm trying to implement Toolbar hiding in Viewpager with Tabs and Listview. In the samples (https://github.com/ksoichiro/Android-ObservableScrollView/blob/master/samples/res/layout/activity_viewpagertab.xml#L28) the layout for main activity adds some padding (@dimen/tab_height) to FrameLayout wrapping ViewPager so that it can be visible below the overlaying Toolbar.
Now, after implementing ObservableScrollViewCallbacks, the Header (Toolbar+Tabs) will translateY and leave empty space below the Tabs. I tried changing the padding of the wrapping FrameLayout in onScrollChanged(), but it starts flickering.
Check these two screenshots: http://cl.ly/aaoD and http://cl.ly/abFz Main Activity layout
Fragment layout: