android - 无法在textview中查看所有文本

标签 android

在表行中我有 2 个 TextView 。但是当我试图显示文本时,如果文本长度很长,我就看不到所有的字符串。仅部分可见

  <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/Add"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/restaurant_address"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/Restaurant_add"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="2"
                    android:singleLine="false" />
            </LinearLayout>
        </TableRow>

我没有明白错误是什么..我能知道我做错了什么吗?

我也将 singleline 设置为 false 并将 ellipsize 设置为结束。但我仍然面临同样的问题。

谢谢:)

最佳答案

您可以将 LinearLayout 放在 ScrollView 中,如果 Text 太长,您可以向下滚动,您将看到整个 String 。 . .

<TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

          <ScrollView>  

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/Add"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/restaurant_address"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/Restaurant_add"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="2"
                    android:singleLine="false" />
            </LinearLayout>
           </ScrollView>
        </TableRow>

关于android - 无法在textview中查看所有文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16032788/

相关文章:

android opengl深度测试失败

java - 如何为 Android 中所有单选按钮组中的所有单选按钮设置背景

java - Android 上的 MVC 模式

Android 将信息保存到设备

android - iOS:类似 Android 布局的相对定位

Android View /布局屏蔽

android - 在安卓中分享截图

android - 将大量图像加载到钛 ImageView 中

java - 将包含 textview 值的文件 .txt (ArrayList) 中的所有项目设置为 ListView [Android Java]

Android 构建失败 - 诊断,ImagePicker 插件依赖不匹配