Scrolling is not smooth while using 3 recyclerviews inside nestedscrollview in android - android

I have three recyclerviews in a single layout file which have horizontally aligned layoutmanagers and these recyclerviews are inside nestedscrollview and I've set the nestedscrolling for each of the three recyclerviews to false too.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/frameLayout"
android:background="#drawable/background">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="FREE MOVIES"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="#color/colorAccent"
/>
<view
android:id="#+id/recycler_view"
class="android.support.v7.widget.RecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="PREMIUM MOVIES"
android:textColor="#color/colorAccent"
android:textStyle="bold"
android:textSize="18sp" />
<view
android:id="#+id/recycler_view1"
class="android.support.v7.widget.RecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/tvTrending"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="PACKAGES"
android:textColor="#color/colorAccent"
android:textStyle="bold"
android:textSize="18sp" />
<view
android:id="#+id/recycler_view2"
class="android.support.v7.widget.RecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:dividerHeight="10.0sp" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="center"/>
</FrameLayout>
And this is the layout of a fragment which I've called from a viewpager from MainActivity. Which has a layout like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
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"
tools:context="com.newitventure.musicnepal.MainActivity">
<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/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/tabanim_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include
android:id="#+id/tool_bar"
layout="#layout/toolbar" />
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
android:background="#color/colorPrimaryDark"
app:tabGravity="fill"
app:tabTextAppearance="#style/MyCustomTextAppearance"
app:tabMode="scrollable" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/tabanim_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="#+id/gad_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:visibility="visible">
</LinearLayout>
</RelativeLayout>
The problem is while trying to scroll in this layout the scrolling is not smooth. It gets very laggy while trying to scroll both vertically and horizontally. What might be the issue here?

This has solved my problem:
mRecyclerView.setNestedScrollingEnabled(false);
For details :
Recyclerview inside ScrollView not scrolling smoothly

Okay,
I see three possibilities from the code given
1) You're using a RelativeLayout at the root for your views. While the RelativeLayout is awesome for a lot, it does have its drawbacks. Due to how RelativeLayout is built up it measures itself twice and all children in it. So for every frame currently displayed Android needs to recalculate every view twice.
2) You do have a "rather" deep structure on your views and I think that you for example can get rid of each of the 3 linear layouts you have around the pair of TextView and recycleview.
3) You're doing something heavy in the bindView method when displaying your recyclerviews.
Now all three of these could matter and play a role in making it laggy.
I would probably start with 2 (I don't think this alone will solve it completely, but it should improve the readability and speed of the code)
Then I would check for 3 (If you paste your code for the Adapter I could have a look on it if there's something clear there). If that still doesn't help try 1 (which can be hard as RelativeLayout is very good for structuring code)
Hope it helps!

Related

Making recyclerview fill entire page

I have a page that has a custom recyclerview. I want items I add to the recyclerview to pop up in a list. App was working just fine before I updated my AppCompact library. But essentially, I had anchored my FAB to a Coordinator layout, but I got an IllegalStateException and to resolve that, I had to anchor it to one of the Coordinator layout's children. I picked the recyclerview. But the problem now is that the recycler view does not fill the entire page. It only shows one item (I can scroll through them) but they only take up the space of one - like viewing one at a time. How do I make the layout work like it did before the update?
This is my xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_height="match_parent">
<!--<include layout="#layout/base_toolbar"/>-->
<android.support.design.widget.CoordinatorLayout
android:id="#+id/myCoordinatorLayout"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent"
>
<LinearLayout
android:id="#+id/reminderEmptyView"
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="#drawable/empty_view_bg"
android:layout_width="100dp"
android:layout_height="100dp"/>
<TextView
android:text="Nothing added yet"
android:textColor="#color/secondary_text"
android:textSize="16sp"
android:paddingTop="4dp"
android:paddingBottom="8dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<!--<include layout="#layout/base_toolbar"/>-->
<!--</android.support.design.widget.AppBarLayout>-->
<apps.todo.Utility.RecyclerViewEmptySupport
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:id="#+id/toDoRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.FloatingActionBut
You probably don't need that parent LinearLayout.
Just copy
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
These into your CoordinatorLayout.
Then remove gravity from your Coordinator Layout and change your FloatingActionButton to:
<android.support.design.widget.FloatingActionButton
android:src="#drawable/ic_add_white_24dp"
android:id="#+id/addToDoItemFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="bottom|end"/>
This fixes the connection between your RecyclerView and FAB.
This Blog post may help you as well: https://android.jlelse.eu/coordinatorlayout-basic-8040c74cf426
Try like this:
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/reminderEmptyView"
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="#drawable/empty_view_bg"
android:layout_width="100dp"
android:layout_height="100dp"/>
<TextView
android:text="Nothing added yet"
android:textColor="#color/secondary_text"
android:textSize="16sp"
android:paddingTop="4dp"
android:paddingBottom="8dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<apps.rtkay.pookiev2.todo.Utility.RecyclerViewEmptySupport
android:id="#+id/toDoRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:src="#drawable/ic_add_white_24dp"
android:id="#+id/addToDoItemFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin" />
</android.support.design.widget.CoordinatorLayout>

Wrapping all elements in RecycleView

I have two recyclerViews (one under second). How to make them not to scale and resize to all elements height, so their scrolling won't be necessary and all items will be visible by scrolling main ScrollView?
Now it looks that:
My 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"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="#+id/appBarLayout"
>
<LinearLayout
android:id="#+id/content_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="#+id/ivPoster"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
app:srcCompat="#mipmap/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Title"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01.01.2001" />
<TextView
android:id="#+id/tvRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5.10/10" />
<Button
android:id="#+id/btFav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mark as favourite"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/tvOverview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Lorem Ipsum" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColor="#000df0"
android:text="Trailers:" />
<android.support.v7.widget.RecyclerView
android:id="#+id/trailerRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColor="#000df0"
android:text="Reviews:" />
<android.support.v7.widget.RecyclerView
android:id="#+id/reviewRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
The easiest solution to your problem is to use NestedScrollView instead of ScrollView as the root scrolling element.
but...
if you really think about all this, it's not really a solution in terms of the performance of your code. Because it will look as desired but it will not be really efficient.
If your RecyclerView wraps its contents (the way you want it to) it inflates all items at once, and not really uses its recycling capabilities. It does not reuse any items it just keeps everything in memory. Essentially it becomes a component that creates a ton of Views using an Adapter based on some data, instead of a RecyclerView.
The way you should implement a thing like that is to create an Adapter that inflates multiple types of Views (4 types to be exact in your case), and use a single RecyclerView instead of your whole ScrollView. There are multiple threads here on SO that describe how to create such Adapters. For example here.
To help you a bit more, here's how you should plan your view types:

How to use ScrollView with one RelativeLayout and two LinearLayout?

I have implemented a ScrollView in which i have added a RelativeLayout. In this RelativeLayout a have added two LinearLayout. Each of this contains a TextView and a ListView. Each ListView contains over 25 items. I want to display all the items of both list views and have a single scroll for both. Now, if i add in the first ListView only 3 items and in the second 25, the first one gets no scroll and only the second gets a scroll. If i add in the first ListView 25 items and in the second 3, the first one gets a scroll and the second is not even displayed. How can i do that? Here is my code:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout1">
<TextView
android:text="title1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/productsToBuyTitle" />
<com.example.alexm.shoppinglist.dlv.DragSortListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/dragSortList1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout2"
android:layout_below="#id/linearLayout1">
<TextView
android:text="title2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/allProductsTitle" />
<com.example.alexm.shoppinglist.dlv.DragSortListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/dragSortList2" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
Thanks in advance!
Try this layout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:id="#+id/linearLayout1">
<TextView
android:text="title1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/productsToBuyTitle" />
<com.example.alexm.shoppinglist.dlv.DragSortListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/dragSortList1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:text="title2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/allProductsTitle" />
<com.example.alexm.shoppinglist.dlv.DragSortListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/dragSortList2" />
</LinearLayout>
</LinearLayout>
</ScrollView>
I think that what would be better, not only in terms of scroll, but also considering performance, would be to have a SINGLE listview that inflates all those layouts. You would only have a single scroll to deal with and your performance would also be improved; nested listview with scrollview is not a good idea and the scroll can get tricky and, this way, your listview would only load visible cells (yay, even better performance).
So, you would define a ListView in that layout and use the adapter to inflate each of those views (the TextView and the list content, that is, the cells).
I believe that solves your problem. If you need the code, let me know, I'll update the answer
i HAVE DIVIDEN the screen into two part equally.. hope it will be scrolled now
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout1">
<TextView
android:text="title1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/productsToBuyTitle" />
<com.example.alexm.shoppinglist.dlv.DragSortListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/dragSortList1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout2"
android:layout_below="#id/linearLayout1">
<TextView
android:text="title2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/allProductsTitle" />
<com.example.alexm.shoppinglist.dlv.DragSortListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/dragSortList2" />
</LinearLayout>
</LinearLayout>
</ScrollView>

TextView below NestedScrollView with height wrap_content not visible

Below is the layout file of the bottom sheet. I have a TextView below the nested scroll view. When the content is large, the TextView below the NestedScrollView is not visible. If content of NestedScrollView is small it is visible. I am not getting what's causing this.
Here is my layout file:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/bottom_sheet_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:title="My Title">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="?attr/selectableItemBackgroundBorderless"
android:onClick="#{() -> handler.hideBottomSheet()}"
android:src="#drawable/ic_keyboard_arrow_down_black_24dp" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin">
<RadioGroup
android:id="#+id/selection_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:checkedButton="#+id/mode_1"
android:gravity="center"
android:orientation="horizontal">
<RadioButton
android:id="#+id/mode_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mode_1" />
<RadioButton
android:id="#+id/mode_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mode_2" />
</RadioGroup>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</android.support.v4.widget.NestedScrollView>
<TextView
android:id="#+id/list_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="This text is not visible. I dunno why! :/" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
list_container LinerLayout is inflated on Runtime. There are some reasons I am not using RecyclerView or ListView. This is fairly small, Just a little scrolling sometime.
But the TextView list_description is not being displayed when list_container is large (needs scrolling).
I am not getting it what's going wrong.
Try using android:layout_weight on your NestedScrollView.
In your case, replace the header of your NestedScrollView with:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
Hope that helps =]

Scroll a TextView out the screen

I have a bit of a predicament.
My Layout is currently this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/item_shipping_shipping_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|left"
android:padding="#dimen/margin_16"/>
<View
android:id="#+id/line43"
android:layout_width="match_parent"
android:layout_height="#dimen/line_height"
android:background="#color/light_gray"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.RecyclerView
android:id="#+id/item_shipping_fragment_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:isScrollContainer="true"/>
</LinearLayout>
The TextView is dynamic content set by the server and it can be really long sometimes.
The problem I am having is the TextView can take up the whole screen. This XML is a fragment that is in a TabLayout with a collapsable toolbar. So when I scroll the content I would like the TextView to scroll out the screen, if this is possible. I tried to embed the Textview in a scrollView but this doesn't work as you see about?
Got any ideas how I can still have the CollapsableToolbar collapse as well as scroll the Textview out the screen to reveal the RecyclerView?
Thank you
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true">
<TextView
android:id="#+id/item_shipping_shipping_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|left"
android:padding="#dimen/margin_16"/>
</android.support.v4.widget.NestedScrollView>
<View
android:id="#+id/line43"
android:layout_width="match_parent"
android:layout_height="#dimen/line_height"
android:background="#color/light_gray"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/item_shipping_fragment_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:isScrollContainer="true"/>
</LinearLayout>

Categories

Resources