2012-01-04 84 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