8

I have seen many similar questions to this one but I think this still covers new ground:
1) Hint text disappears when you set gravity
2) android:ellipsize="start" fixes that so you can have centered hints and centered text
3) why does the code below still show centered hint text?

    <EditText
    android:id="@+id/details"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:hint="use this area to provide specific identification information including approximate size, vessel name and registration numbers if available"
    android:background="@android:drawable/editbox_background"
    android:layout_below="@id/details_title"
    />

is it because of fill_parent instead of wrap_content? i thought maybe it was because this hint is multiline, but i shortened it and it still appeared and was centered. those are the only differences between this and my other EditTexts that needed android:ellipsize="start" to display correctly. is it just a bug?

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

2 Answers2

0

add this attribute to your EditText

android:ellipsize="start"

It just works

<EditText
android:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:ellipsize="start"
android:hint="use this area to provide........"
android:background="@android:drawable/editbox_background"
android:layout_below="@id/details_title"
/>
HimalayanCoder
  • 9,630
  • 6
  • 59
  • 60
0

You need to use android:gravity="top" instead of center in order to have your hint and your text start at the top left of the box.

Phil
  • 35,852
  • 23
  • 123
  • 164
  • i don't want it at the top or the left ... i want it centered. your solution also does nothing about the visibility of the hint which was the whole point in the question. – dylan murphy Jun 09 '11 at 12:37