【发布时间】:2017-08-08 08:37:55
【问题描述】:
我已经尝试过alerts,但似乎无法让android只换行..
即具有以下内容:
This is line number 1 /r/n
This is a much much longer line number 2.. please don't wrap me /r/n
我很高兴滚动查看右侧的内容。
我尝试过应用滚动视图包装器以及 scrollHorizontally="true" 但没有成功。
当我不想要它时,任何太长的行都会换行。
注意: 文本都在一个 StringBuilder 中。与/r/n 行正确中断,但如果太长(我不想要)也会中断换行。设置最大行数是行不通的,因为我想要多行......
我正在尝试按原样显示文件的内容。
我目前的布局(尝试了其他东西)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/white"
android:clipToPadding="false"
android:fillViewport="true"
android:scrollbarStyle="outsideOverlay">
<TextView
android:id="@+id/tv_file_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:lineSpacingExtra="5dp"
android:padding="10dp"
android:scrollHorizontally="true"
android:scrollbars="horizontal"
android:text="some very long test in a line which hopefully shouldnt wrap as tht would be a crime against humanity :( lets now see"
android:textColor="@color/black"
android:textSize="20sp"/>
</ScrollView>
</LinearLayout>
【问题讨论】: