In my app I six edit texts. I’ve grouped them in two linear layouts, 3 in on linear layout.
It should look something like this:
|EditText1|EditText4|
|EditText2|EditText5|
|EditText3|EditText6|
I want to edit texts are always the same size.
The problem occurs when users start to type something in field. If texts is too long…edit are texts are resizing. The one with focus gets biggers, and the one in the same horizontal row gets smaller.
How to prevent this?
I want to edit text stays the same size…if text is too long…i simple need to scroll it and follow text cursor.
How to do that? TNX!
Here some code:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="3" >
<EditText
android:id="@+id/blackPlayerName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/black_name_selector"
android:hint="@string/black"
android:inputType="textPersonName"
android:maxLength="12"
android:singleLine="true"
android:textColor="@drawable/player_name_textcolor"
android:textColorHint="@drawable/player_name_textcolor" />
<EditText
android:id="@+id/redPlayerName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/red_name_selector"
android:hint="@string/red"
android:inputType="textPersonName"
android:maxLength="12"
android:singleLine="true"
android:textColor="@drawable/player_name_textcolor"
android:textColorHint="@drawable/player_name_textcolor" />
<EditText
android:id="@+id/whitePlayerName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/white_name_selector"
android:hint="@string/white"
android:inputType="textPersonName"
android:maxLength="12"
android:singleLine="true"
android:textColor="@color/black"
android:textColorHint="@color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="3" >
<EditText
android:id="@+id/bluePlayerName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/blue_name_selector"
android:hint="@string/blue"
android:inputType="textPersonName"
android:maxLength="12"
android:singleLine="true"
android:textColor="@drawable/player_name_textcolor"
android:textColorHint="@drawable/player_name_textcolor" />
<EditText
android:id="@+id/greenPlayerName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/green_name_selector"
android:hint="@string/green"
android:inputType="textPersonName"
android:maxLength="12"
android:singleLine="true"
android:textColor="@drawable/player_name_textcolor"
android:textColorHint="@drawable/player_name_textcolor" />
<EditText
android:id="@+id/yellowPlayerName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="@drawable/yellow_name_selector"
android:hint="@string/yellow"
android:inputType="textPersonName"
android:maxLength="12"
android:singleLine="true"
android:textColor="@color/black"
android:textColorHint="@color/black" />
</LinearLayout>
</LinearLayout>
For each of your edit texts set their layout_width to 0dp and layout_weight to 1