How to make the height fixed and still while adding more numbers that it can show to the EditText?

StackOverflow https://stackoverflow.com/questions/21341873

Pergunta

I used this code to put in 1 line two EditText's, but when I type more numbers that the field can show, it gets big enough until show all numbers(including hidding other blank EditText's), and with this, change the height of all the next buttons on the code.

The TableRow selected is the same as the one on the code below

code http://imagizer.imageshack.us/v2/800x600q90/21/bm0c.png

Here's the code:

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

    <EditText
        android:id="@+id/num1"
        android:layout_height="50.0sp"
        android:layout_width="fill_parent"
        android:hint="@string/Numero1"
        android:inputType="numberDecimal"
        android:scrollHorizontally="true" />

    <EditText
        android:id="@+id/num2"
        android:layout_height="50.0sp"
        android:layout_width="fill_parent"
        android:hint="@string/Numero2"
        android:inputType="numberDecimal"
        android:scrollHorizontally="true" />
</TableRow>
Foi útil?

Solução

Do this-

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

    <EditText
        android:id="@+id/num1"
        android:layout_width="fill_parent"
        android:layout_height="50.0sp"
        android:hint="@string/Numero1"
        android:inputType="numberDecimal"
        android:scrollHorizontally="true"
        android:singleLine="true" />

    <EditText
        android:id="@+id/num2"
        android:layout_width="fill_parent"
        android:layout_height="50.0sp"
        android:hint="@string/Numero2"
        android:inputType="numberDecimal"
        android:scrollHorizontally="true"
        android:singleLine="true" />
</TableRow>

add "android:singleLine" attribute, this will keep your Edittext limited to one row only.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top