Reputation: 51
So I've been facing this weird problem with RecyclerView
scroll.
Let me first tell you about my requirements:
ToolBar
. Sort of like a sliding
drawer layout that opens from top when a button is clicked. I
achieved this by creating a custom sliding drawer. This drawer
visibility is set to GONE at the beginning. When the user clicks on
the menu icon, the visibility is set to VISIBILE.CoordinatorLayout
with ToolBar
which includes a menu button.ToolBar
which shrinks when scrolled.SwipeToRefreshLayout
with RecyclerView
inside.I am facing two problems:
RecyclerView
scroll is not at all smooth. When I scroll to the
bottom, the list item is only visible after a second. It gets stuck
in between when scrolling the first time. I'm sure there must be
something that be done to scroll smoothly.RecyclerView
is completely gone. Not sure
why. Please find screenshot below on this problem Look at Screenshoots
[![enter image description here][1]][1]
I am completely helpless on how to fix this, so any help is appreciated.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.app.ranky.menu.Transparent
android:id="@+id/popup_window"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left">
<LinearLayout
android:background="#320d77"
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:layout_marginTop="@dimen/margin_large"
android:id="@+id/menu_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TableLayout
android:layout_marginTop="-10dp"
android:layout_marginLeft="@dimen/margin_large"
android:layout_marginRight="@dimen/margin_large"
android:layout_marginBottom="@dimen/margin"
android:layout_width="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*"
android:layout_height="wrap_content">
<TableRow
android:layout_marginRight="@dimen/margin"
android:layout_marginLeft="@dimen/margin"
android:layout_marginBottom="@dimen/margin"
android:id="@+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ImageView android:src="@drawable/ic_whatsapp"
android:id="@+id/id_whatsapp"
android:layout_weight="1"
android:padding="@dimen/padding_small"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:src="@drawable/ic_fb"
android:id="@+id/id_fb"
android:layout_weight="1"
android:padding="@dimen/padding_small"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:src="@drawable/ic_mail"
android:id="@+id/id_mail"
android:layout_weight="1"
android:padding="@dimen/padding_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
</TableRow>
</TableLayout>
</LinearLayout>
</com.app.ranky.menu.Transparent>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="183dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<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:expandedTitleMarginBottom="32dp"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_home_banner"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<ImageButton
android:src="@drawable/ic_slidemenu"
android:background="@null"
android:id="@+id/slide_menu_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.app.ranky.views.CustomTextView
android:paddingRight="45dp"
android:text="@string/app_name"
android:id="@+id/app_title"
android:layout_centerInParent="true"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#cfccd8"
app:font="circular_book" />
<RelativeLayout
android:layout_gravity="right"
android:gravity="right"
android:paddingTop="@dimen/padding"
android:paddingBottom="@dimen/padding"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingLeft="@dimen/padding_large"
android:paddingRight="@dimen/padding_large"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:layout_alignParentRight="true"
android:src="@drawable/ic_plus_small"
android:background="@drawable/add_app_circle"
android:id="@+id/app_add_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<com.app.ranky.views.CustomSwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_overlapTop="30dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listOfferItems"
android:listSelector="#00000000"
android:fadingEdge="none" android:fadingEdgeLength="0dp"
android:cacheColorHint="@android:color/transparent"/>
</com.app.ranky.views.CustomSwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
public class Transparent extends LinearLayout {
public Transparent(Context context, AttributeSet as) {
super(context, as);
}
public Transparent(Context context) {
super(context);
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
}
}
Upvotes: 0
Views: 1579
Reputation: 51
Ok. So I fixed it using this code:
appBarLayout.setExpanded(false, false);
It was because the appBarLayout was expanding when the menu was displayed.
Upvotes: 0