2

I wanted to set the height of collapsing toolbar dynamically based on height of fragments, as you can see when the sign in screen is scrolled to top and a lot of blank spaces appeared which makes the app to look weird, so i just wanted to know how can i make the collapsing toolbar to scroll only if i have more than available space,

I had tried my many efforts but failed like this question other searched link, but it just disable the scrolling but i wanted the scroll along with fixed scrolling of fragments, so in hope of getting help, i am posting my question

This is my main xml, code as follows,

<android.support.design.widget.CoordinatorLayout 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/dimen_collapsing"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            app:tabMode="fixed"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_gravity="bottom"
            app:tabIndicatorColor="@color/color_00cdb"
            app:tabIndicatorHeight="@dimen/dimen_tab_indicator_height"
            app:tabSelectedTextColor="@color/color_2323"
            app:tabTextAppearance="@style/TextAppearance.AppCompat.Subhead"
            app:tabTextColor="@color/color_8e90" />

        <include layout="@layout/layout_toolbar"
            app:layout_collapseMode="pin" />


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

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

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

The other two fragments one is signup and other is signin,

Signin xml is as follows,

This is the xml, whose layout looks weird, when scrolled to top as it have only few items to show, so i just wanted to know how can i make it to scroll if more than available space is required.

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_margin="@dimen/dimen_layout_margin"
        android:id="@+id/fsi_la_container"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fsi_tl_email"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_email"
                android:hint="@string/s_signup_hint_email" />

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fsi_tl_password"
            android:background="@android:color/transparent"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_password"
                android:hint="@string/s_signup_hint_password"
                android:id="@+id/textInputEditText" />
        </android.support.design.widget.TextInputLayout>

    </LinearLayout>
</RelativeLayout>

Signup xml is as follows, This is the xml, whose layout looks good, when scrolled to top as it have many items to show

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

    <LinearLayout
        android:id="@+id/fs_lay_container"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_margin="@dimen/dimen_layout_margin"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fs_tl_fName"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_user_icon"
                android:hint="@string/s_signup_hint_fName" />

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fs_tl_lName"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_user_icon"
                android:hint="@string/s_signup_hint_lName" />

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fs_tl_email"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_email"
                android:hint="@string/s_signup_hint_email" />

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fs_tl_countryCode"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_mobile"
                android:hint="@string/s_signup_hint_countryCode" />

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fs_tl_phone"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_mobile"
                android:hint="@string/s_signup_hint_phone" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fs_tl_password"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_password"
                android:hint="@string/s_signup_hint_password" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fs_tl_cPassword"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:drawableLeft="@drawable/di_password"
                android:hint="@string/s_signup_hint_cPassword" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/fs_tl_address"
            style="@style/textInputLayout">

            <android.support.design.widget.TextInputEditText
                style="@style/edittext"
                android:imeOptions="actionDone"
                android:drawableLeft="@drawable/di_address"
                android:hint="@string/s_signup_hint_address" />
        </android.support.design.widget.TextInputLayout>
    </LinearLayout>

    <TextView style="@style/textView"
        android:layout_below="@+id/fs_lay_container"
        android:id="@+id/fs_tv_tCondition"
        android:text="@string/s_signup_tCondition"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>

    <Button style="@style/button"
        android:layout_marginTop="@dimen/dimen_layout_margin"
        android:layout_below="@id/fs_tv_tCondition"
        android:id="@+id/fs_bt_save"
        android:text="@string/s_signup"/>
</RelativeLayout>

Initial View on Collapsing toolbar

On Scroll of SigninScreen

On Scroll of Signup Screen

Thanks in advance,

any help would be greatly appreciated.

Community
  • 1
  • 1
Reprator
  • 2,859
  • 2
  • 32
  • 55

0 Answers0