Reputation: 5150
I am using Appbarlayout followed by cordinatorlayout with a RecyclerView to just collapse/expand a simple TextView. But still don't know whats I am doing wrong there. The TextView(textViewMainTop) still not collapsing/expanding .Not able to findout the issue. Please have a look on my xml code.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="7"
android:orientation="vertical" >
<!-- <LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3.5" > -->
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3.5">
<com.openskylabs.skymo.components.TypefacedTextView
android:id="@+id/textViewMainTop"
style="@style/custom_roboto_midium"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bubbled_textview"
android:gravity="center"
app:layout_scrollFlags="scroll|enterAlways"
android:text="Good evening, Eric"
android:textSize="17dp" />
</android.support.design.widget.AppBarLayout>
<!-- </LinearLayout> -->
<LinearLayout
android:id="@+id/llTabLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="6.5"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/llFirstFavTab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_fev_small" />
<com.openskylabs.skymo.components.TypefacedTextView
style="@style/custom_roboto_midium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5sp"
android:text="Set Fav" />
</LinearLayout>
<View
android:id="@+id/viewVertical"
android:layout_width="0.5sp"
android:layout_height="match_parent"
android:background="#60000000" />
<LinearLayout
android:id="@+id/llSecondInviteTab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:visibility="visible" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_cont_small" />
<com.openskylabs.skymo.components.TypefacedTextView
style="@style/custom_roboto_midium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5sp"
android:text="Invite" />
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/viewBelowRay"
android:layout_width="match_parent"
android:layout_height="1sp"
android:background="#60000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#eaeaea"
android:gravity="center"
android:orientation="vertical" >
<android.support.v7.widget.RecyclerView
android:id="@+id/rvOrderList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Here I want to collapse the first part. In in second part I am using RecyclerView.
Upvotes: 0
Views: 1152
Reputation: 11255
You should use CollapsingToolbarLayout
with AppBarLayout
to collapse the widgets you want. Your Text View
goes inside CollapsingToolbarLayout
.
Like this.
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="250dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
Upvotes: 1