2012-08-15 38 views
0

如果文本比LinearLayout允许的空间更长,我希望文本多行,如下图顶部所示。这是我在手机上运行应用程序(HTC Desire HD)时发生的情况,但是当我在平板电脑(东芝Thrive)上运行应用程序时,会发生偏移,如下图所示:Android:textview在平板电脑上使用椭圆化,而在手机上多行时

what I want on top, what happens on bottom

我有一个由行组成的ListView。每行定义如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:weightSum="4" 
    android:gravity="center_vertical" 
    > 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_weight="1" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:textStyle="bold" 
      android:id="@+id/codeLabel" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
     </TextView> 
     <TextView 
      android:id="@+id/code" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
     </TextView> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/description" 
     android:layout_weight="3" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     /> 

</LinearLayout> 

我该如何解决这个问题?

+0

你有没有试过这个:http://stackoverflow.com/questions/4152726/how-to-wrap-text-to-next-line-in-android-textview?rq=1 – brthornbury 2012-08-15 17:34:50

+0

@Mozoby我试过用android :scrollHorizo​​ntally =“false”本身并没有工作,但使用它与android:inputType =“textMultiLine”做了诡计!但是,此行下面有一个黄色的波浪形状,它给了我警告:“属性android:inputType不应与一起使用:将元素类型更改为?” – Kalina 2012-08-15 18:50:49

回答

-1

我曾试过单独他们失败了,但在一起

android:scrollHorizontally="false" 
android:inputType="textMultiLine" 

的伎俩......虽然我得到“的inputType”不应​​该的TextView使用的警告。

相关问题