EditText 提示不显示
我的 EditText
配置如下,不会显示提示:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:hint="The hint..."
android:scrollHorizontally="true"
android:singleLine="true" />
如果我设置 android:gravity="left"
或删除 android:scrollHorizontally
,它就会起作用。 code> 和 android:singleLine 属性,这是不可取的。有什么建议吗?
My EditText
configured as follows won't show the hint:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:hint="The hint..."
android:scrollHorizontally="true"
android:singleLine="true" />
It works if I set android:gravity="left"
or if I remove android:scrollHorizontally
and android:singleLine
attributes, which is not desirable. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
使用
android:ellipsize="end"
为我修复了它奇怪的错误! (但是Android有很多这些奇怪的bug)
using
android:ellipsize="end"
fixed it for meWeird bug !! (but Android has a lot of these weirdo bug)
在 Lollipop 版本中,
EditText
的默认文本和提示文本颜色为白色。所以我们必须在
EditText
中进行这样的更改In Lollipop version the default text and hint text color is white for
EditText
.So we have to change like this in
EditText
我希望我的单行
EditText
框能够滚动,但也将提示保留在右侧。我遇到了同样的问题,并通过保持
gravity="right"
并设置singleLine="true"
和ellipsize="end"< 得到了坚持的提示/代码>。
I wanted my single-line
EditText
box to scroll but keep the hint on the right also.I had the same issue and got the hint to stick by keeping
gravity="right"
, and settingsingleLine="true"
andellipsize="end"
.你需要给文字颜色来提示
You need to give text color to hint
不需要
android:scrollHorizontally
属性。删除它。EditText
是屏幕上的固定项目。我们想要滚动的布局包含EditText就足够了。这也是最好的设计。您已放置android:ellipsize="end"
而不是android:scrollHorizontally
。No need of
android:scrollHorizontally
attribute. Remove it.EditText
is a fixed item on the screen. we want scroll the layout contains the EditText is enough. that is the best design too. you have putandroid:ellipsize="end"
instead ofandroid:scrollHorizontally
.使用 android:ellipsize="end" 解决了明显的平台错误。不幸的是,Xperias 仍然表现不佳:(
除了以下之外,我没有找到其他解决方案:
Using android:ellipsize="end" resolves the obvious platform bug. Unfortunately, Xperias still misbehave :(
I found no other solution than to:
尝试改变提示文字颜色,有时提示颜色与背景颜色相同
Try changing the hint text color, sometimes the hint color is the same as the background color
以下内容对我有用:
The below worked for me:
这就是我通过
EditText
所做的,以在其中提供提示。This is how, I did for by
EditText
to have hint in it.我将样式更改为“@style/Base.WidgetMaterialComponents.TextImputEditText”。对我来说,这不是重力或颜色。
I changed the style to
"@style/Base.WidgetMaterialComponents.TextImputEditText"
. For me it wasn't gravity or color.在我的android工作室中是dolphin(旧版本)并且我设置了compileSdkVersion 33所以这个问题出现然后我compileSdkVersion 32设置。运行良好。因此降低compileSdkVersion版本。
In my android studio is dolphin(old version) and I have set compileSdkVersion 33 so this issue come then i compileSdkVersion 32 set. It's working fine. So decrease compileSdkVersion version.