Why does android:singleLine="true" change width and height?

380 Views Asked by At

Iv'e already set the EditText width and height, I want the user will press next on keyboard and he will move to the next EditText, but when I set android:singleLine="true", the width and height are changing. Here is my code:

<EditText
        android:id="@+id/user2"
        android:saveEnabled="false"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="40dp"
        android:background="@color/Alpha_White"
        android:ems="10"
        android:height="37dp"
        android:hint="@string/hint_username"
        android:maxLength="22"
        android:paddingLeft="7dp"
        android:textColorHint="#DDAAAAAA"
        android:textSize="17sp"
        android:width="230dp"
        android:imeOptions="actionNext"
        />
1

There are 1 best solutions below

0
On BEST ANSWER

You do not need to have android:layout_width and android:width in the same View. android:width value will be ignored. Use only android:layout_width and android:layout_height and put your fixed values there, like this:

android:layout_width="230dp"
android:layout_height="37dp"

Use android:singleLine="true" to allow your EditText to have only one line.