can a TextView grow horizontally in Kotlin?

41 Views Asked by At

I'm making an interface for a landed tablet. It has a HorizontalScrollView and inside has a TextView. When I display it, the text goes all the way down and at the end of the layout the text ends abruptly. I wanted it to be continued in the following column. This is my code now:

<HorizontalScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:padding="20dp">

                <LinearLayout>...</LinearLayout>

                <TextView
                    android:id="@+id/txtBody"
                    android:layout_height="match_parent"
                    android:layout_width="500dp"
                    android:layout_margin="12dp"
                    android:textSize="16sp"
                    android:text="@{notice.text}"
                    tools:text="@tools:sample/lorem/random"/>

            </LinearLayout>

I've tried changing the original text to html and setting android:scrollHorizontally="true" for the text view, but it does not work either...

1

There are 1 best solutions below

0
Thommy On BEST ANSWER

The TextView does not automatically create a new column. It sticks to the size you gave it with layout_width or any hardcoded size and writes the text running text to this width. If you want one Text in multiple columns you need to calculate the contents yourself, here is a good tutorial: https://accella.net/knowledgebase/multi-column-text-displays-in-android/