Reputation: 806
By default my EditText has next view:
<EditText android:layout_height="wrap_content" android:paddingLeft="10dip"
android:layout_width="wrap_content" android:gravity="center_vertical"
android:inputType="textShortMessage"
android:id="@+id/search_string" android:background="@drawable/search_text_bg">
<requestFocus></requestFocus>
</EditText>
When I input text to it, it changes self size and background stretches. how to avoid it?
Upvotes: 0
Views: 184
Reputation: 40503
android:layout_width="match_parent"
OR
android:layout_width="fill_parent" // deprecated
OR
android:layout_width="50dip" // Manually assign any width you want.
Upvotes: 1
Reputation: 26974
One simple solution is to have android:layout_width="match_parent"
and android:singleLine="true"
Upvotes: 1
Reputation: 128428
There are some attributes you need to set:
If you want to have single line edit text then do:
android:singleLine="true"
If you want to define maximum lines for edit text then do:
android:maxLines="3"
Upvotes: 2