EditText 提示随重力消失
我见过很多与此类似的问题,但我认为这仍然涵盖了新的领域:
1) 设置重力时提示文字消失
2) android:ellipsize="start"
修复了这个问题,这样您就可以拥有居中的提示和居中的文本
3)为什么下面的代码仍然显示居中的提示文本?
<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"
/>
是因为fill_parent而不是wrap_content吗?我想也许是因为这个提示是多行的,但我缩短了它,它仍然出现并且居中。这些是它与我的其他需要 android:ellipsize="start"
才能正确显示的 EditText 之间的唯一区别。这只是一个错误吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用
android:gravity="top"
而不是 center 以使提示和文本从框的左上角开始。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.将此属性添加到您的 EditText
它就可以了
add this attribute to your EditText
It just works