【问题标题】:Too much of words make the words go out of the screen太多的单词使单词消失在屏幕上
【发布时间】:2019-03-09 08:12:16
【问题描述】:

描述2 如果我写的字太多。这个词将转到屏幕之外。如何解决?

这是我的 XML 代码之一,我正在使用带有 TextView 的表格布局。

<TableRow android:layout_width="282dp">
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Description2:"
                        android:textColor="#000"
                        android:textSize="20sp"
                        android:textStyle="bold" />
                    <TextView
                        android:id="@+id/txtDescription2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Description2 Here"
                        android:textColor="#000"
                        android:textSize="20sp"/>
                </TableRow>

有没有办法让它一直显示在 Description2 的底部?提前谢谢...

【问题讨论】:

标签: android user-interface interface


【解决方案1】:

您想要多行的长文本? 你可以使用这个选项。

android:layout_weight

<TableRow android:layout_width="282dp">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Description2:"
                    android:textColor="#000"
                    android:layout_weight="1"
                    android:textSize="20sp"
                    android:textStyle="bold" />
                <TextView
                    android:id="@+id/txtDescription2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Description2 Here"
                    android:textColor="#000"
                    android:layout_weight="3"
                    android:textSize="20sp"/>
            </TableRow>

插入两个文本视图,android:layout_weight 1,android:layout_weight 3。它会工作。

我推荐给你。

在 xml 中添加此代码。

android:singleLine="true"
android:ellipsize="marquee"

并在 java 代码中选择此文本视图。因为这在专注时有效。

TextView text = (TextView)findViewById(R.id.text);
text.setSelected(true);

它在单行中显示所有文本。文本移动缓慢。 此解决方案,文本长度不会改变 UI。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多