2012-01-04 75 views
0

我真的不喜歡問這些小問題,但在數小時後,它看起來像死衚衕。EditText在添加一個新行之前缺少字符

我在Android中遇到了編輯文本的問題。這是非常基本的,沒有風格適用於它。

問題是,如果我開始輸入它,當它達到最後的最大寬度,而不是添加一個換行符時,它會奇妙地「擴展」EditText寬度,並讓我插入大約10或12個字符,然後再實際添加一個新的線。顯然,所有這些10-12個字符都是「看不見」的。我真的不知道爲什麼會發生這種情況,任何幫助都會很受歡迎!

這是我的佈局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:gravity="center_horizontal" 
    android:background="@drawable/fondo_localizacion"> 

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_margin="5dp" 
     android:stretchColumns="1"> 

     <TableRow > 
     <TextView 
    android:id="@+id/locationNameLabel" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       style="@style/LabelLocalizacion" 
       android:gravity="center_vertical" 
       android:text="@string/nombre_label"> 
      </TextView> 
      <EditText 
       android:id="@+id/locationName" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       > 
      </EditText>  
     </TableRow> 
     <!-- La segunda fila tiene el par desc y su valor --> 
     <TableRow > 
      <TextView 
       android:id="@+id/locationDescLabel" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       style="@style/LabelLocalizacion" 
       android:gravity="center_vertical" 
       android:text="@string/desc_label"> 
      </TextView> 
      <EditText 
       android:id="@+id/locationDesc" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       > 
      </EditText>  
     </TableRow> 

     <TableRow > 
      <TextView 
       android:id="@+id/locationPicLabel" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       style="@style/LabelLocalizacion" 
       android:gravity="center_vertical" 
       android:text="@string/imagen_label"> 
      </TextView> 
     </TableRow> 
</TableLayout> 
+0

對於哪個EditText你有問題嗎? – Ian 2012-01-04 09:46:17

+0

我曾爲它,無論是,@ loks解決方案工作得很好,謝謝你無論如何:) – AlejandroVK 2012-01-04 11:00:49

回答

1

嘗試給予高度和寬度,以錶行標籤移除機器人:stretchColumns =「1」從tablelayout並把重的EditText的爲1,你可以使用此佈局修改後

  <TableRow 
     android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 

     <TextView 
     android:id="@+id/locationNameLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:text="gfg" > 
     </TextView> 

    <EditText 
     android:id="@+id/locationName" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:hint="hjhj" > 
     </EditText> 
    </TableRow> 
    <!-- La segunda fila tiene el par desc y su valor --> 

     <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <TextView 
     android:id="@+id/locationDescLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:text="yuiuy" > 
     </TextView> 

    <EditText 
     android:id="@+id/locationDesc" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" > 
    </EditText> 
</TableRow> 

<TableRow 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:id="@+id/locationPicLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:text="" > 
    </TextView> 
</TableRow> 

+0

這工作非常感謝! – AlejandroVK 2012-01-04 10:54:10

0

嘗試使的EditText具有固定的數值寬度,而不是WRAP_CONTENT