noties / Scrollable

Android scrollable tabs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

View Pager not taking the complete height even on using "match parent"

RohitK1992 opened this issue · comments

Hi Dimitry,

Whenever I scroll up the scrollablelayout, there is a certain blank space left behind which I suppose belongs to the activity holding the view pager, can you please tell me what is wrong with my code.

My Activity Layout :

<include
    android:id="@+id/action_bar_points"
    layout="@layout/custom_action_bar_toolbar" />

<ru.noties.scrollable.ScrollableLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollable_layout"
app:scrollable_autoMaxScroll="true"
app:scrollable_autoMaxScrollViewId="@+id/header"
app:scrollable_considerIdleMillis="125"
app:scrollable_friction="0.050"
app:scrollable_closeUpAnimationMillis="250"
app:scrollable_defaultCloseUp="true"
app:scrollable_scrollerFlywheel="false"
app:scrollable_closeUpAnimatorInterpolator="@android:anim/accelerate_decelerate_interpolator">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/points_parent"
    android:orientation="vertical"
    android:background="@color/app_bg">

<LinearLayout
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:id="@+id/header"
    android:layout_height="wrap_content">

        <RelativeLayout
            android:layout_width="140dp"
            android:layout_height="140dp"
            android:background="@drawable/circle_my_points_bg"
            android:layout_marginTop="@dimen/margin15dp"
            android:layout_marginBottom="@dimen/margin15dp"
            android:layout_centerHorizontal="true"
            android:layout_gravity="center"
            android:id="@+id/circular_relative_view">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/star_icon"
                android:text=""
                android:layout_centerHorizontal="true"
                android:layout_marginTop="@dimen/margin10dp"
                android:padding="@dimen/margin5dp"
                android:textSize="16sp"
                android:textColor="@color/orange_text"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/level_text_points"
                android:layout_below="@id/star_icon"
                android:layout_centerHorizontal="true"
                android:text=""
                android:layout_marginTop="@dimen/margin5dp"
                fontPath="fonts/Gotham-XLight.otf"
                android:textSize="16sp"
                android:textColor="@color/orange_text"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/level_points"
                android:layout_below="@id/level_text_points"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="@dimen/margin10dp"
                android:text="9400"
                fontPath="fonts/Gotham-XLight.otf"
                android:textSize="20sp"
                android:textColor="@color/black"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/reward_points_text"
                android:layout_below="@id/level_points"
                android:layout_centerHorizontal="true"
                android:text=""
                android:padding="4dp"
                fontPath="fonts/Gotham-XLight.otf"
                android:textSize="12sp"
                android:textColor="@color/black"/>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:id="@+id/points_indicator"
            android:layout_below="@id/circular_relative_view"
            android:layout_marginTop="@dimen/margin20dp"
            android:padding="@dimen/margin5dp"
            android:visibility="gone">
        </RelativeLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/light_gray"
            android:layout_marginTop="@dimen/margin15dp"
            android:layout_marginLeft="@dimen/margin10dp"
            android:layout_marginRight="@dimen/margin10dp"
            android:layout_below="@id/points_indicator"/>

    </LinearLayout>

             <android.support.design.widget.TabLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/points_tablayout"
                app:tabMode="fixed"
                app:tabGravity="fill"
                app:tabIndicatorColor="@color/app_bg"
                app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
                app:tabSelectedTextColor="@color/orange_text"
                app:tabTextColor="@color/black"/>

            <android.support.v4.view.ViewPager
                android:id="@+id/points_viewpager"
                android:layout_width="match_parent"
                android:layout_height="fill_parent"
                android:background="@color/app_bg"
                android:layout_below="@id/points_tablayout"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
               />

    </LinearLayout>
</ru.noties.scrollable.ScrollableLayout>

Viewpager fragment 1:

?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/redeem_recyclerview"
android:background="@color/app_bg"
android:clipToPadding="false"
android:numColumns="auto_fit"
android:padding="@dimen/item_offset"/>

Hey!
I think that you need to put your +@id/header the first child in the ScrollableLayout. Something like this:

<ru.noties.scrollable.ScrollableLayout
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scrollable_layout"
    app:scrollable_autoMaxScroll="true"
    app:scrollable_autoMaxScrollViewId="@+id/header"
    app:scrollable_considerIdleMillis="125"
    app:scrollable_friction="0.050"
    app:scrollable_closeUpAnimationMillis="250"
    app:scrollable_defaultCloseUp="true"
    app:scrollable_scrollerFlywheel="false"
    app:scrollable_closeUpAnimatorInterpolator="@android:anim/accelerate_decelerate_interpolator">

    <LinearLayout
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:id="@+id/header"
        android:layout_height="wrap_content">

        <RelativeLayout
            android:layout_width="140dp"
            android:layout_height="140dp"
            android:background="#ff0"
            android:layout_marginTop="15dip"
            android:layout_marginBottom="15dip"
            android:layout_centerHorizontal="true"
            android:layout_gravity="center"
            android:id="@+id/circular_relative_view">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/star_icon"
                android:text=""
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dip"
                android:padding="5dip"
                android:textSize="16sp"
                android:textColor="#f00"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/level_text_points"
                android:layout_below="@id/star_icon"
                android:layout_centerHorizontal="true"
                android:text=""
                android:layout_marginTop="5dip"
                android:textSize="16sp"
                android:textColor="#f00"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/level_points"
                android:layout_below="@id/level_text_points"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dip"
                android:text="9400"
                android:textSize="20sp"
                android:textColor="#000"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/reward_points_text"
                android:layout_below="@id/level_points"
                android:layout_centerHorizontal="true"
                android:text=""
                android:padding="4dp"
                android:textSize="12sp"
                android:textColor="#000"/>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:id="@+id/points_indicator"
            android:layout_below="@id/circular_relative_view"
            android:layout_marginTop="20dip"
            android:padding="5dip"
            android:visibility="gone">
        </RelativeLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#ccc"
            android:layout_marginTop="15dip"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:layout_below="@id/points_indicator"/>

    </LinearLayout>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/points_parent"
        android:orientation="vertical">

        <android.support.design.widget.TabLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/points_tablayout"
            app:tabMode="fixed"
            app:tabGravity="fill"
            app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
            app:tabSelectedTextColor="#f00"
            app:tabTextColor="#000"/>

        <android.support.v4.view.ViewPager
            android:id="@+id/points_viewpager"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:layout_below="@id/points_tablayout"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    </LinearLayout>
    
</ru.noties.scrollable.ScrollableLayout>