Android:重心的Edittext在设备上不起作用 [英] Android: Edittext with gravity center not working on device

查看:24
本文介绍了Android:重心的Edittext在设备上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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在设备上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆