ListView中的TextViews仅显示字符串中的第一个单词,其中不经常显示空格

时间:2015-07-24 06:11:09

标签: android listview textview

在对话框中,我有一个包含多个textview的列表视图。问题是,如果我重新调整模式,那么在某些textview的auto之后它会不一致地截断该值。但是从来没有一次textview显示整个文本。

我无法理解为什么会发生这种情况,也不确定它可能截断的其他值组合。我已经尝试了其他带有空格的值并且它正确显示但是现在它在" auto"中创建了问题。只有单词。甚至尝试过UPPERCASE,但结果仍然相同。

ListView布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RadioButton
        android:id="@+id/radioBtncustomerAddress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="10dp"
        android:text="Address Type"
        android:gravity="top"
        android:checked="false"/>



    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginLeft="50dp"
        android:layout_marginBottom="10dp"
        android:layout_weight="1"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textviewcustomershipbilladdress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Address" />

        <TextView
            android:id="@+id/textviewcustomershipbillstreet"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <requestFocus />
        </TextView>

        <TextView
            android:id="@+id/textviewcustomershipbillarea"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbillcity"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbillstate"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbillcountry"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbillpincode"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbilldistrict"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </LinearLayout>
</LinearLayout>

ListView适配器中的代码

holder.text1.setText("auto street");
holder.text2.setText("auto add");
holder.text3.setText("auto district");
holder.text4.setText("auto pin");
holder.text5.setText("auto area");
holder.text6.setText("auto country");
holder.text7.setText("auto city");
holder.text8.setText("auto state");

DISPLAY

auto street
auto add
auto 
auto pin
auto area
auto 
auto city
auto state

1 个答案:

答案 0 :(得分:0)

只需将内部线性布局宽度设为match_parent,其工作正常

<LinearLayout
    android:layout_width="match_parent"<!--Set it to me match_parent-->
    android:layout_height="match_parent"
    android:layout_marginLeft="50dp"
    android:layout_marginBottom="10dp"
    android:layout_weight="1"
    android:orientation="vertical" >