My project contains an activity_main.xml Layout and 3 fragments xml layouts in a ViewPager. Fragments 2 and 3 ("help_us" and "conversation")contain a RecyclerView. Frgemnent 2 contains a linear layout with an EditText.
I just want to hide AppBar when scrolling the Recyclerviews!
I followed this tutorial https://mzgreen.github.io/2015/06/23/How-to-hideshow-Toolbar-when-list-is-scrolling%28part3%29/ without a result.
So I have two questions: 1- What did I miss ??? 2- When I Enter some text in the EditText in Fragment 2...guess what? the Appbar collapses! and never comes back... This is clearly not a desired behavior...
Does anyone see how could I solve these issues?
Here are my Layouts
activity_main.xml
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_black_matxxxhdpi"
android:fitsSystemWindows="true"
app:statusBarBackground="@android:color/transparent"
tools:context="com.example.philipp.us.MainActivity">
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="550dp"
android:background="@drawable/background_black_logo_white_mediumxxxhdpi"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@android:color/transparent"
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="56dp"
android:layout_marginLeft="45dp"
android:layout_marginRight="20dp"
android:background="@android:color/transparent"
android:elevation="4dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.AppBarOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/submit_question"
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_gravity="top|center_horizontal"
android:layout_marginEnd="10dp"
android:background="@android:color/transparent"
android:clickable="true"
android:onClick="onSubmitQuestion"
app:backgroundTint="@android:color/transparent"
app:fabSize="normal"
app:layout_anchor="@+id/container"
app:layout_anchorGravity="bottom|right|center"
app:srcCompat="@drawable/_btn_askus_normalxxxhdpi"
app:useCompatPadding="true" />
</android.support.design.widget.CoordinatorLayout>`
fragment 2.xml
<LinearLayout 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:layout_marginBottom="10dp"
android:background="@android:color/transparent"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:weightSum="100"
tools:context="com.example.philipp.us.HelpUsFragment">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white_transparent">
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:background="@android:color/transparent"
android:paddingStart="8dp"
android:weightSum="100">
<ImageButton
android:id="@+id/btn_localisation"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginEnd="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_weight="10"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:cropToPadding="false"
android:onClick="onUpdateFilterLocation"
android:scaleType="centerCrop"
android:tint="@color/white_transparent"
app:srcCompat="@drawable/custom_button_localisation_filter"
tools:ignore="ContentDescription,NestedWeights" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_weight="20"
android:background="@android:color/transparent"
android:orientation="vertical"
android:weightSum="100">
<EditText
android:id="@+id/lbl_filter_city"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:background="@android:color/transparent"
android:ellipsize="end"
android:gravity="center"
android:hint="@string/hint_city_search"
android:inputType="text|textCapWords|textAutoCorrect"
android:lines="1"
android:maxLines="1"
android:minLines="1"
android:scrollHorizontally="true"
android:selectAllOnFocus="true"
android:textAlignment="center"
android:textColor="@color/white"
android:textColorHint="@color/white_transparent"
android:textColorLink="@color/colorHintText"
android:textSize="12sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:background="@android:color/transparent"
android:elevation="0dp"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100"
tools:targetApi="lollipop">
<EditText
android:id="@+id/lbl_filter_value_radius"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="50"
android:background="@android:color/transparent"
android:hint="@string/hint_radius_filter_novalue"
android:inputType="number"
android:lines="1"
android:maxEms="3"
android:maxLength="3"
android:maxLines="1"
android:minLines="1"
android:scrollHorizontally="true"
android:selectAllOnFocus="true"
android:textAlignment="viewEnd"
android:textColor="@color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/lbl_unit_distance"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="3dp"
android:layout_marginStart="3dp"
android:layout_weight="50"
android:background="@android:color/transparent"
android:text="@string/unit_distance"
android:textAlignment="textStart"
android:textColor="@color/white_transparent"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
android:orientation="horizontal"
android:visibility="gone">
</LinearLayout>
<EditText
android:id="@+id/lbl_filter_keyword"
style="@style/EditTextTheme"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="60"
android:backgroundTint="@color/white_transparent"
android:clipToPadding="true"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜßäöüŒÀÂÇÈÉÊËÎÏÔÛÜœàâçèéêëîïôùûüáíóúñÑ-"
android:gravity="center_vertical"
android:hint="@string/hint_search_filter"
android:imeOptions="actionSearch"
android:inputType="textCapWords|textAutoCorrect"
android:maxLines="1"
android:minLines="1"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:selectAllOnFocus="true"
android:textColor="@color/white"
android:textColorHint="@color/white_transparent"
android:textSize="18sp" />
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
android:orientation="horizontal"
android:visibility="gone">
</LinearLayout>
<ImageButton
android:id="@+id/btn_filter_search"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight="10"
android:background="@android:color/transparent"
android:onClick="onFilterQuestions"
android:scaleType="centerInside"
android:tint="@color/white_transparent"
app:srcCompat="@drawable/custom_button_search"
tools:ignore="ContentDescription" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swiperefresh"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="93">
<android.support.v7.widget.RecyclerView
android:id="@+id/question_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:fadingEdgeLength="10dp"
android:isScrollContainer="false"
android:requiresFadingEdge="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
fragment 3.xml
<LinearLayout 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"
android:background="@android:color/transparent"
android:orientation="vertical"
android:weightSum="100"
tools:context=".ConversationFragment">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white_transparent">
</FrameLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/conv_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:fadingEdgeLength="10dp"
android:paddingTop="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
Thank you very much
I solved my problem. For the posterity: in my activity_main.xml, Viewpager layout had a fixed value for: android:layout_height="550dp". So, with android:layout_height="match_parent" was the problem solved.
Now, the whole activity_main layout slightly outpass the phone borders.
If someone see what happend, i would be grateful for a solution.