0

我对 android 很陌生,我正在设计一个表格布局,每行包含两个 textview。问题是如果文本很长,textview 中的文本会被截断。我也使用了包装内容和应用权重,但对我没有帮助。布局代码如下

        <TableLayout
            android:id="@+id/tableLayout"
            style="@style/fill_parent_wrap_content" >

            <TableRow style="@style/both_wrap_content" >

                <TextView
                    style="@style/InfoTextView1"
                    android:text="@string/customerName"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/txtDetailCustomerName"
                    style="@style/InfoTextView1" />
            </TableRow>

            <TableRow style="@style/both_wrap_content" >

                <TextView
                    style="@style/InfoTextView1"
                    android:text="@string/caNumberDetail"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/txtDetailCaNo"
                    style="@style/InfoTextView1" />
            </TableRow>

            <TableRow style="@style/both_wrap_content" >

                <TextView
                    style="@style/InfoTextView1"
                    android:text="@string/customerAddress"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/txtDetailAddress"
                    style="@style/InfoTextView1"
                    />
            </TableRow>
</TableLayout>
</Scrollview>


    This is a style that i apply to textviews
   <style name="InfoTextView1">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_marginLeft">5dp</item>
    <item name="android:paddingTop">15dp</item>
    <item name="android:textColor">@color/Black</item>
    <item name="android:textSize">@dimen/text_size_small</item>
    </style>
4

2 回答 2

1

尝试这个..

 <TableRow 
   android:layout_height="wrap_content"
   android:layout_width="match_parent"
   android:weightSum="2">

  <TextView 
       android:layout_height="50dp"
       android:layout_width="0dp"
       android:layout_weight="1"
       android:singleLine="true"
       android:ellipsize="marquee"/>
   <TextView 
       android:layout_height="50dp"
       android:layout_width="0dp"
       android:layout_weight="1"
       android:singleLine="true"
       android:ellipsize="marquee"/>

   </TableRow>

然后将此行放入java文件中textview.setSelected(true);

于 2013-06-15T09:45:19.860 回答
0

显示 TableLayout 和 TableRows 的样式...

我敢打赌,问题出在他们身上。

于 2013-06-15T09:37:59.337 回答