0

I've got an EditText...

 <EditText android:id="@+id/box" android:autoText="true"
 android:layout_width="fill_parent" android:layout_height="45dip"
 android:singleLine="true" android:hint="Enter" />

Is it possible to make the text only appear up on till say... 50dip from the end of the EditText?

So when typing a query it'd look like

 ____________________
 |y query is cool   |
 --------------------

while typing my query is cool

inazaruk
  • 74,247
  • 24
  • 188
  • 156
Skizit
  • 43,506
  • 91
  • 209
  • 269

3 Answers3

3

You can use paddingRight in this case (assuming I understood you correctly). Here is an example:

 <EditText android:id="@+id/box"
        android:autoText="true"
        android:layout_width="fill_parent"          
        android:layout_height="wrap_content"
        android:paddingRight="50dp"                                     
        android:singleLine="true"
        android:hint="Enter" 
        android:text="1234567890ABCDEF-1234567890ABCDEF"/>

enter image description here

inazaruk
  • 74,247
  • 24
  • 188
  • 156
2

The best alternative is to create your own nine-patch file and decide exactly how much padding you want.

See my answer here for a quick intro: How to create android spinner without down triangle on the right side of the widget

and the official docs here:

Then, you should use

android:gravity="right"

inside your EditText

Community
  • 1
  • 1
Aleadam
  • 40,203
  • 9
  • 86
  • 108
0

im a little confused also as to what you were going for, my first thought would be to add

<EditText android:id="@+id/box"
android:autoText="true"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:singleLine="true"
android:ellipsize="start"
android:hint="Enter" />

but maybe that wasn't what you meant? you could use this in combination with the techniques listed about so that the user wouldn't be confused by the missing characters.

dylan murphy
  • 1,370
  • 1
  • 18
  • 33