Reputation: 329
I have following layout in my android application.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bbg">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0">
<TableRow>
<EditText
android:id="@+id/TestEdit"
android:hint="Test"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<Button
android:id="@+id/TestButtin"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text = "Test"/>
</TableRow>
</TableLayout>
</LinearLayout>
<com.google.android.maps.MapView
android:id="@+id/MapView" android:clickable="true"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:apiKey="KEY" />
</LinearLayout>
The problem is, that when I change text in EditText using setText() method, if text is too long EditText scratches and pushes Button out of screen. I don't want EditText to scrath, but I want it to be also I want it to be "fill_parent" by default/
How can I fix it? Thanks.
Upvotes: 0
Views: 109
Reputation: 372
I hope this helps:
<EditText
android:id="@+id/TestEdit"
android:text="EditText01dsfasdfadsfsdafdsafdasfasdfsadfdsfdfadfasdfsd"
android:hint="Test"
android:singleLine="true"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"/>
Upvotes: 0
Reputation: 323
You need to use the android:maxLength
, android:maxEms
,android:maxLines
properties to restrict the width of your EditText
Upvotes: 1