开发者

EditText hint disappears with gravity

I have seen many similar questions to this one but I think this still c开发者_C百科overs 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?


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.


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"
/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜