How do I put a scrollView inside a TextView if I already have a scrollView in the layout?

1

I put a scrollview in the layout and still needed to put a scrollview in TextView, however only one of them works, if it already has in the layout, the textView does not work. Does anyone know a way to leave them both? Thank you in advance.

    
asked by anonymous 29.01.2016 / 17:35

1 answer

1

using NestedScrollView There are some solutions you could add in order to get this job but there is no need for it. Android Support Library v4 has a class called NestedScrollView and it does exactly what the name suggests.

Example:

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<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:padding="@dimen/default_padding"
            android:layout_height="@dimen/nested_scroll_view_height">

        <TextView
                android:text="@string/hello_world"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"/>

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

    <include layout="@layout/cards_layout"/>

</LinearLayout>

Most of the time you probably do not need two scrollviews on the same screen, but if you need it, NestedScrollView is a great solution. This class has a set of handy methods so you can disable nested scrolling, make sure your nested scrolling display has nested parent scrolling, and so on.

You can check the official documentation for more information. link

    
29.08.2016 / 16:47