Android: Edittext with gravity center not working on device(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在设备上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android:重心的Edittext在设备上不起作用
基础教程推荐
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
