AlejandroVK
AlejandroVK

Reputation: 7605

EditText missing characters before adding a new line

I really don't like asking about these little issues, but after diggin for hours, it looks like a dead end.

I'm having a strage issue with a EditText in Android. It is very basic and no styles appplied to it.

The problem is that if I start typing on it, when it reaches the last maximum width, instead of adding a newline it "expands" the EditText width magically and lets me insert about 10 or 12 characters before actually adding a new line. Obviously all those 10-12 characters are "out of sight". I really don't know why this is happening, any help will be very welcome!

Here is my layout:

<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>

Upvotes: 0

Views: 626

Answers (2)

loks
loks

Reputation: 490

Try to give height and width to Table Row tag remove android:stretchColumns="1" from tablelayout and put weight of edittext to 1 you can using this layout after modify

         <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>

Upvotes: 1

Mohamed_AbdAllah
Mohamed_AbdAllah

Reputation: 5322

Try making the EditText with fixed numeric width rather than wrap_content

Upvotes: 0

Related Questions