How to put a scrollView inside a Textview if I already have a scrollView in the layout?

Asked

Viewed 689 times

1

I put a scrollView in the layout and still needed to put a scrollview in Textview, but only one of them works, if I already have the layout, textView does not work. Does anyone know a way to leave the two? Thanks in advance.

  • I never got to use it, but the support library v4 has the NestedScrollView, which should be interesting in this case.

  • You have one answer that can help you here: http://stackoverflow.com/questions/1748977/making-textview-scrollable-in-android

  • I had already seen this answer. It happens the same problem, either works the scroll of Textview or works the layout?

  • I have the same problem, you managed to solve?

  • Does anyone know the solution to this problem?

  • @daniel12345smith Have a ScrollView within one another is not good practice. You can improve your code by showing only part of the text and inserting a 'Alertdialog' to show your full text;.

Show 1 more comment

1 answer

1

using Nestedscrollview There are some solutions you could add in order to get to this job, but there is no need for that. Support library Android 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 don’t need two scrollviews on the same screen, but if you need it Nestedscrollview is a great solution. This class has a set of useful methods so you can disable nested scrolling, check whether your nested scrolling display has nested parent scrolling and so on.

can check the official documentation for further information. https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.