Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to make a TextView Scroll insider a RecyclerView

$
0
0

I have a RecyclerView which contains different classes of items in the list.

One of these is a TextView which may contain enough text that I would like to scroll it within the recyclerView rather than have the RecyclerView item expand to accomodate it.

The first step here was to add a ScrollView around the TextView and set android:fillViewport="false" to stop the RecyclerView expanding to accomodate it.

That part worked OK. but there was no scrolling available of the the TextView (only the RecyclerView.).

So in the ViewHolder class I added (for the ScrollView)

            Scroller = itemView.FindViewById<NestedScrollView>(Resource.Id.bodyScroller);
            Scroller.NestedScrollingEnabled = true;

However, Scrolling was still not possible for the TextView,

I then changed ScrollView for NestedScrollView - no change.

I then added a CoordinatorLayout around the NestedScrollView - still no change

Current XML is as follows :
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="0dp"
card_view:cardUseCompatPadding="false"
card_view:cardCornerRadius="0dp">

      <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical"
          android:paddingLeft="10dp"
           android:paddingTop="5dp"
           android:paddingBottom="5dp"
          android:layout_alignParentLeft="true">

            <android.support.design.widget.CoordinatorLayout
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">

              <android.support.v4.widget.NestedScrollView
                android:id="@+id/bodyScroller"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scrollbars="vertical"
                android:fillViewport="false">

                <TextView
                      android:id="@+id/fieldNote"
                      android:layout_centerVertical="true"
                      android:layout_weight="1.0"
                      android:textAppearance="@style/MessageBodyTextAppearance"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:background="@color/lightGray"
                      android:scrollbars="vertical" />

              </android.support.v4.widget.NestedScrollView>
            </android.support.design.widget.CoordinatorLayout>

      </LinearLayout>
    </android.support.v7.widget.CardView>

Any suggestions please ?
Thanks.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>