ScrollView - Как включить горизонтальную прокрутку в ScrollView - PullRequest
0 голосов
/ 21 апреля 2020

Итак, у меня есть ScrollView, внутри которого TextView. Когда String для текста длиннее ширины экрана, он просто сдвигается на следующей строке. Я хочу избежать новой подкладки, добавив HorizontalScrolling в ScrollView. Кроме того, я хочу сделать текст выбираемым, чтобы пользователь мог копировать текст. Возможно ли это?

        <ScrollView
            android:id="@+id/scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">

                <TextView
                    android:id="@+id/text_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="15dp"
                    android:layout_marginEnd="15dp"
                    android:layout_marginBottom="15dp"
                    android:ellipsize="end"
                    android:textIsSelectable="true"
                    android:justificationMode="inter_word"
                    android:lineSpacingExtra="5dp"
                    android:textSize="15sp"
                    tools:targetApi="o" />
        </ScrollView>

Ответы [ 2 ]

0 голосов
/ 21 апреля 2020
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:scrollbars="vertical">

    <HorizontalScrollView 
        android:layout_width="match_parent" android:layout_height="wrap_content">

        <FrameLayout android:layout_width="320dp"
            android:layout_height="match_parent" 
            android:background="#000000"/>

    </HorizontalScrollView>

</ScrollView>
0 голосов
/ 21 апреля 2020

Попробуйте это:

<HorizontalScrollView 
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<TextView 
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:scrollHorizontally="true"
        android:text="Horizontal scroll text view"/>

</HorizontalScrollView>
...