Android:编辑文本重力中心不工作在设备上 [英] Android: Edittext with gravity center not working on device
问题描述
在Android中,我使用一个单独的edit文本,重力设置为中心。在模拟器这工作伟大的提示和闪烁的光标显示。当在设备(Xperia X10)上测试时,提示文本和闪烁的光标都不显示。
In Android I'm using a single line edittext with gravity set to center. In the Emulator this works great both the hint and a blinking cursor shows up. When testing on device (Xperia X10) neither the hint text nor the blinking cursor shows up. The blinking cursor only shows if I enter some text into the edittext.
这是我的编辑文字,任何人都可以看到是否有遗漏吗?
This is my edittext, can anyone see if something is missing?
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ellipsize="end"
android:maxLines="1"
android:gravity="center"
android:layout_gravity="center"
android:hint="Some hint text"
></EditText>
</LinearLayout>
我想要的:
代码(没有光标的空白edittext):
What I get with the above code (empty edittext with no cursor):
推荐答案
我终于找到了解决方案,这个EditText适用于我:(在Sony Ericsson X10和HTC Wildfire上测试)
I finally found the solution to get it working. This EditText works for me: (Tested on Sony Ericsson X10 and HTC Wildfire)
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:digits="0123456789.,"
android:ellipsize="start"
android:maxLines="1"
android:gravity="center"
android:hint="Some hint text"
></EditText>
这篇关于Android:编辑文本重力中心不工作在设备上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!