【问题标题】:text is not fully displayed in textview文本未在 textview 中完全显示
【发布时间】:2018-02-28 16:49:01
【问题描述】:

Textview ["text_body_story"] 未完全显示内容。我使用了以下 xml 代码。我使用了一个ListView,然后选择其中一个项目时,它会从String数组显示我分配的字符串。我的字符串非常大,有时多达 4000 个单词。以下 xml 代码位于相对布局内。

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

    <TextView
        android:id="@+id/text_story_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:fontFamily="sans-serif-condensed"
        android:text="text_story_name"
        android:textSize="16sp"
        android:textAllCaps="true"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:textStyle="bold" />
    <TextView
        android:id="@+id/text_author_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="text_author_name"
        android:textAlignment="center"
        android:textSize="14sp"
        android:textStyle="bold|italic" />

    <Space
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:background="#000000"

        />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:background="#000000"
        app:srcCompat="?attr/actionModeSplitBackground" />

    <TextView
        android:id="@+id/text_body_story"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="text_body_story"
        android:inputType="textMultiLine"
        android:singleLine="false"
        android:padding="10dp"
        android:layout_marginBottom="10dp"/>

</LinearLayout>



</ScrollView>

如何在 textView 中显示整个文本?

【问题讨论】:

标签: android string textview


【解决方案1】:

要显示多行添加:

android:ellipsize="none" //the text is not cut on textview width

android:scrollHorizontally="false"   //the text wraps on as many lines as necessary 

【讨论】:

  • 它没有用。我已经试过了。我还有什么其他建议可以做吗?
【解决方案2】:

我推荐使用:

<TextView
        android:singleLine="false"
/>

android:ellipsize="end"
android:singleLine="true"

android:layout_width="wrap_content"

android:inputType="textMultiLine"

【讨论】:

  • 哇..好奇怪。
猜你喜欢
  • 2014-10-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-29
  • 1970-01-01
  • 1970-01-01
  • 2014-07-18
  • 1970-01-01
相关资源
最近更新 更多