2012-12-02 76 views
0

我列出了一些文本視圖中的視圖。其中一個文本視圖有時會在其他文本視圖中有一個長字符串時被推出視圖它。如何防止我的ListvView中的視圖被推出視圖

如何使文本視圖的橢圓化並從不推送其他視圖?

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

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 
     <TextView 
      android:id="@+id/rest_name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 

      android:maxLines="2" 
      android:ellipsize="end" 
      android:text="Name" 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="right" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/rest_rating" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="1.5" 
       android:singleLine="true" 
       android:textAppearance="?android:attr/textAppearanceLarge" /> 
     </LinearLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/rest_type" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 
     android:ellipsize="end" 
      android:singleLine="true" 
      android:capitalize="words" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="right" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/rest_open" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:paddingLeft="5dp" 
       android:text="Open" 
       android:singleLine="true" 
       android:textAppearance="?android:attr/textAppearanceSmall" /> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 

回答

0

我知道這很奇怪,但如果你把

 android:capitalize="words" 

你應該看到你想要的結果。你甚至不需要android:ellipsize="end"

<TextView 
     android:id="@+id/rest_type" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left" 
     android:singleLine="true" // <-- the play maker 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 
+0

它不工作。它不只是rest_type它的任何textview,但maintly rest_name – code511788465541441

+0

也許你可以嘗試使用固定值或match_parent的邊界 – mango

相關問題