英文:
can a TextView grow horizontally in Kotlin?
问题
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>
</HorizontalScrollView>
I've tried changing the original text to HTML and setting android:scrollHorizontally="true"
for the text view, but it does not work either.
英文:
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
得分: 0
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/
英文:
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/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论