gpt4 book ai didi

Android 并在 TableRow 的 TextView 中显示多行文本

转载 作者:IT王子 更新时间:2023-10-28 23:44:25 25 4
gpt4 key购买 nike

我正在显示一个 TableLayout,其行如下:

<?xml version="1.0" encoding="utf-8"?>
<TableRow
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

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

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/one"
android:layout_marginLeft="10dip"
android:textColor="#B0171F" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/one"
android:id="@+id/two"
android:layout_marginLeft="10dip"
android:ellipsize="none"
android:singleLine="false"
android:scrollHorizontally="false"
android:maxLines="10"
android:textColor="@android:color/black" />

</RelativeLayout>

</TableRow>

我正在用我能在这里找到的所有东西来实现这一点,并且可以想到允许文本在多行上换行但无济于事:文本总是被强制为一行,从屏幕上跑出来。我在这里的 TableRow 中工作可能很重要,据我所知,这个网站上还没有处理过。

那么,如何强制我的第二个 TextView 换行到多行?

最佳答案

如果文本所在的列设置为缩小,则 TextView 将包装文本。有时它不完全换行,如果文本以“,...”结尾,那么它比正好 n 行长一点。

下面是一个例子,id为question的TextView会换行:

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*">
<TableRow>
<TextView
android:id="@+id/question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>

关于Android 并在 TableRow 的 TextView 中显示多行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5230290/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com