問題描述
在 Android 中,我使用單行編輯文本,并將重力設置為中心.在模擬器中,提示和閃爍的光標都顯示出來了.在設備 (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>
我想要什么:
我用上面的代碼得到了什么(沒有光標的空編輯文本):
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:重心的Edittext在設備上不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!