【问题标题】:Textview lines not wrapping correctlyTextview 行没有正确换行
【发布时间】:2012-05-08 17:17:00
【问题描述】:

我有一个 ListView,我为每一行创建了一个自定义视图。我的视图由两个要并排显示的文本视图组成。第一个文本视图(idno)有一个背景图像集,我将文本居中。第二个文本视图(材料)的每一行都有可变数量的行。

我遇到的问题是线条在换行之前超出了右侧。似乎没有考虑到第一个 textview 的宽度。

这是我的布局文件:

<TableLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<TableRow>
    <TextView 
        android:id="@+id/idno"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:gravity="center"
        android:textColor="#000000"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>    
    <TextView 
        android:id="@+id/materials"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:textColor="#0000ff"
        android:textStyle="bold"
        android:textSize="12sp"
        android:maxLines="5"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="10sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</TableRow> 

任何建议或解决方案将不胜感激。提前致谢!

【问题讨论】:

    标签: android android-layout android-listview textview


    【解决方案1】:

    我建议您使用 LinearLayoutorientation="horizontal" 来显示两个 TextView,例如:

    <LinearLayout
        android:orientation="horizontal">
        <TextView/>
        <TextView/>
    </LinearLayout>
    

    【讨论】:

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