0

我有一个 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> 

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

4

1 回答 1

1

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

<LinearLayout
    android:orientation="horizontal">
    <TextView/>
    <TextView/>
</LinearLayout>
于 2012-05-08T17:21:53.727 回答