Prevent EditText from expanding with long text

0

I have a EditText and two buttons in a relative layout. The problem is that when writing a text that is too long in EditText , even if it fits, the text is displayed behind the buttons. I would like to know if you can limit it to where it expands, put a fixed size and make it possible to put the same text even if you do not see everything written (with a function similar to the bar of a browser in which the URL is written ).

This is my code regarding these three elements that, as I said, are in the same RelativeLayoout

  <EditText
                android:id="@+id/IH"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:inputType=""
                android:text="@string/texto3"
                android:textColor="?android:attr/textColorTertiary"
                android:textStyle="italic" />

            <Button
                android:id="@+id/guardar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_toEndOf="@+id/editText17"
                android:layout_toRightOf="@+id/editText17"
                android:background="?attr/colorAccent"
                android:text="@string/bot1"
                android:textColor="@android:color/background_light" />

            <Button
                android:id="@+id/borrar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/guardar"
                android:layout_alignLeft="@+id/guardar"
                android:layout_alignRight="@+id/guardar"
                android:layout_alignStart="@+id/guardar"
                android:layout_below="@+id/guardar"
                android:text="@string/bot2"
                android:textColor="@android:color/background_light" />
    
asked by pepito 26.07.2017 в 16:35
source

1 answer

2

The way to solve your problem is the following:          

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/editText"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="textPersonName" />

        <Button
            android:id="@+id/button2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:id="@+id/button"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

    </LinearLayout>
</RelativeLayout>

If you ask why I put a LinearLayout to contain those 3 elements, the answer is easy, if you use LinearLayout , you can assign to the 3 elements the match_parent property and they must be accommodated, remember that the property wrap_content adjusts to the size of the component , so if the content of the component grows, it will grow with it. If for some reason, when you put the property match_parent does not fit, you can select the 3 from the editor and use the following option:

    
answered by 26.07.2017 / 16:45
source