所以我有一个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>
<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>
尝试一下:
<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>