【问题标题】:Textview that doesn't show full text不显示全文的文本视图
【发布时间】:2014-03-17 01:21:01
【问题描述】:

我正在使用包含两个 TextView 的 TableLayout 和 TableRow 创建一个简单的布局。这是代码的一部分。

<TableLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:stretchColumns="0">

    <TableRow android:id="@+id/myTableRow">

    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:padding="15dip"
        android:text="Short description"/>

    <TextView 
        android:id="@+id/textView1"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:padding="15dip"
        android:text="Large description"/>

    </TableRow>

问题是如果 TextView1 中有长文本,则不会显示全文。如何在 TextView1 中显示全文?

【问题讨论】:

  • 您希望文本显示为多行并换行吗?
  • 如果文字很长,是的,我要显示多行
  • 听起来不是很粗鲁,但你应该先用谷歌搜索答案。这个问题有很多解决方案。

标签: java android xml tableview


【解决方案1】:

显示多行添加:

android:ellipsize="none" //文本没有在textview宽度上剪切:

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

【讨论】:

    【解决方案2】:

    试试更新 XML 你有什么问题...可能这就是你想要做的。

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    
        <TableRow android:id="@+id/myTableRow" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="15dip"
                android:text="Short description" />
    
            <TextView
                android:id="@+id/textView1"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="15dip"
                android:text="Large description" />
        </TableRow>
    
    </TableLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-28
      • 1970-01-01
      • 2019-02-08
      • 1970-01-01
      • 2021-11-20
      • 2016-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多