Search code examples
androidandroid-edittext

How to set long text inside editext in such a way that it must display the end of the text?


i m creating a browser for my self.so when i set text of edittext by passing the url of some link it shows only the beginning of the url.Ex- if the url is

https://stackoverflow.com/howtocreateabutton/

but the edittext shows only

https://stackoverflow.com/how

beacuse of overflow from the screen but i want to display the last of the link like -

com/howtocreateabutton/

Xml Code for Edittext:

    <EditText
    android:layout_width="0dp"
    android:layout_height="40dp"
    android:layout_weight="10"
    android:onClick="enterAgain"
    android:layout_marginTop="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:inputType="textUri"
    android:gravity="center_vertical"
    android:hint="Enter URL..."
    android:autoText="true"
    android:layout_marginRight="10dp"
    android:textColorHighlight="#4384d4"
    android:textColor="#c1bfbf"
    android:maxLines="1"
    android:scrollHorizontally="true"
    android:foregroundGravity="right"
    android:clickable="true"
    android:imeOptions="actionGo"
    android:id="@+id/edit_url"
    android:background="#FFFFFF"/>

....help me guys...;(


Solution

  • you can do it as following:

    et.setSelection(et.getText().length());
    

    i tested and it worked for me if anything went wrong put let me know in the comments