0

I would like to add some transitioning text to the collapsed version of the collapsed toolbar I have a collapsed toolbar with a tablayout and a textview with text underneath the tablayout. Both of which are in collapsing toolbar.

How could I get the text from the TextView to transition into the space of the collapsed toolbar

I have searched online but none of them are solutions to my problem

This is my layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".AddExpenseSheetActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/expense_bar_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/expense_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:popupTheme="@style/AppTheme.PopupOverlay">

            <TextView
                android:id="@+id/expense_bar_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginRight="?android:attr/actionBarSize"
                android:gravity="center"
                android:text="@string/placeholder_text"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

        </androidx.appcompat.widget.Toolbar>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/expense_bar_container">


        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/tab_layout_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="12dp"
            android:fitsSystemWindows="true"
            android:theme="@style/AppTheme.AppBarOverlay">


            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:id="@+id/tab_collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:minHeight="40dp"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleGravity="bottom|center_horizontal"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">


                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior">

                    <com.google.android.material.tabs.TabLayout
                        android:id="@+id/expense_account_tab"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="?attr/colorPrimaryDark"
                        android:elevation="12dp"
                        android:minHeight="?attr/actionBarSize"
                        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                        app:tabIndicatorColor="@android:color/white"
                        app:tabIndicatorGravity="top"
                        app:tabIndicatorHeight="10dp"
                        app:tabMode="scrollable" />

                    <androidx.cardview.widget.CardView
                        android:id="@+id/expense_amount_cardView"
                        android:layout_width="match_parent"
                        android:layout_height="150dp"
                        android:layout_below="@id/expense_account_tab"
                        android:layout_gravity="center"
                        android:elevation="10dp"
                        card_view:cardBackgroundColor="?attr/colorPrimaryDark"
                        card_view:cardCornerRadius="5dp"
                        card_view:cardElevation="10dp"
                        card_view:cardUseCompatPadding="false">


                        <TextView
                            android:id="@+id/expense_text_view"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_gravity="center"
                            android:contentDescription="@string/expense_text_desc"
                            android:gravity="center"
                            android:text="$00000.00"
                            android:textAlignment="center"
                            android:textColor="@android:color/white"
                            android:textSize="75sp" />


                    </androidx.cardview.widget.CardView>


                </RelativeLayout>


            </com.google.android.material.appbar.CollapsingToolbarLayout>


        </com.google.android.material.appbar.AppBarLayout>


        <include layout="@layout/content_add_expense" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

</RelativeLayout>

enter image description here

enter image description here

I want the $0000.00 to transition into the space below the toolbar. How do I do this?

Brown
  • 121
  • 3
  • 10
  • Add the toolbar and text in the collapsingtoolbarlayout – sanjeev Jul 15 '19 at 04:20
  • I have a tablayout and textview inside the collapsingtoolbar already however the textview is not the toolbar. I don't want the toolbar to change I just want the $0000.00 text to transition below the toolbar with the collapsing toolbar – Brown Jul 15 '19 at 04:24
  • Well in that case why do you add on the root? Add it in the fragments which you use for the `tablayout`.. – sanjeev Jul 15 '19 at 04:25
  • Any idea how I can do that? How would I create such an animation then? Also, the tablayout is added in an activity. Is there a way to dynamically change the position of the text view to show on top of the collapsing toolbar? – Brown Jul 15 '19 at 04:36
  • You will have to create child layouts for tablayout.. What have you returned in your tabadapter class? – sanjeev Jul 15 '19 at 04:51
  • try it In this link you have similar problems [link 1](https://stackoverflow.com/questions/31302121/correct-way-to-change-collapseable-toolbar-title) [link 2](https://stackoverflow.com/questions/35259610/how-to-have-a-textview-transition-to-the-title-in-a-collapsing-toolbar) – Javad Shakouri Jul 15 '19 at 05:51
  • @JavadShakouri I have tried the one you have provided in the link 2 and the issue with this is the text then appears above the tab layout and I need it strickly below it. That is why I have appbar layouts one containing only my toolbar, and the other with collapsing view. – Brown Jul 15 '19 at 17:24

0 Answers0