Question

I have XML like this :

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="@string/button1" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignTop="@+id/button1"
        android:layout_toLeftOf="@+id/button1"
        android:ems="10"
        android:inputType="textMultiLine" />
</RelativeLayout>

And the view like this :

enter image description here

How can I fix that?

Was it helpful?

Solution

The problem is that you are using the android:ems attribute, which sets an exact width to the TextView (measured in EMs).

This overrides android:layout_width="wrap_content", and thus the text in the EditText overflows.

I'm guessing what you actually wanted was to set the size of the text, which should be done using android:textSize and SP units.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top