0

I have a HomeActivity which has tabs containing fragments. In which BoardFragment has children RecyclerView and a RelativeLayout(at bottom). My Toolbar collapses when I scroll up. But my RealtiveLayout on the bottom also coordinate with them. Only the upper part part of it is shown on oncreate. It shows up completely when I scroll up.

Here are the sreenshots.

On oncreate. Bottom Relative Layout is shown partially only.

When I scroll up, as the toolbar collapses Bottom Relative Layout is shown.

HomeActivity.

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/appbar_padding_top"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_menu_white_24dp"
            />

        <Spinner
            android:id="@+id/spinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:minWidth="150dp"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            />
    </android.support.v7.widget.Toolbar>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_input_add"
    android:visibility="invisible" />

Board Fragment.

<FrameLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="io.sleeko.fragment.BoardFragment"
android:background="#dadada">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/boardMainContentList"
        >
    </android.support.v7.widget.RecyclerView>

    <com.github.rahatarmanahmed.cpv.CircularProgressView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/spinningProgressView"
        android:layout_width="36dp"
        android:layout_height="36dp"
        android:padding="4dp"
        android:background="@drawable/white_circle_drawable"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="150dp"
        app:cpv_thickness="3dp"
        app:cpv_color="#ff161a73"
        app:cpv_animAutostart="true"
        app:cpv_indeterminate="true"
        android:elevation="4dp"
        />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="96dp"
        android:layout_alignParentBottom="true"
        android:duplicateParentState="true"
        android:background="#ffffff"
        android:padding="8dp"
        android:id="@+id/sendMessageContainer"
        >
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Write a Message"
            android:padding="8dp"
            android:background="@android:color/transparent"
            />
        <android.support.design.widget.FloatingActionButton
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            app:fabSize="mini"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            android:id="@+id/sendButton"
            android:src="@drawable/ic_send_white_24dp"
            />
    </RelativeLayout>
</RelativeLayout>

Can anyone help me solve this? Thanks.

Midhun Vijayakumar
  • 2,927
  • 2
  • 19
  • 23

1 Answers1

1

I have encountered a similar problem before. you wont need app:layout_behavior="@string/appbar_scrolling_view_behavior" inside viewpager inside HomeActivity layout. I think this will solve your problem.

Nabeel K
  • 5,938
  • 11
  • 38
  • 68
  • Thank you Man. You saved me. But I'm still having a problem here. Now a part of my RecyclerView is clipped off (upper part). It's behind toolbar and tab now. Adding a margin doesn't work as desired. any solution? – Midhun Vijayakumar Oct 16 '15 at 16:06
  • I didnt get you. can you post the image ? – Nabeel K Oct 16 '15 at 16:17
  • 1
    Thank you Mr Beast. But I just got it solved. I put that Relative Layout in home Activity and made it visible only when that particular fragment is selected. Now everything is perfect. – Midhun Vijayakumar Oct 16 '15 at 19:42
  • thats great. All the best – Nabeel K Oct 17 '15 at 07:16
  • I am encountering the same problem and tried the solution, but it isn't working. The relative layout at the bottom isnt visible initially and then is still scrolling up as i scroll the recyclerview. Please help. – Abhriya Roy Nov 15 '17 at 14:58