Android:EditText 没有被省略
我有 2 个线性布局的 EditText,它们没有被省略,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#696969"
android:layout_marginBottom ="5px">
<EditText
android:id="@+id/addressbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft ="2px"
android:layout_marginRight ="1.5px"
android:layout_weight="0.35"
android:textSize = "15sp"
android:singleLine="true"
android:editable = "true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="end"
android:imeOptions="actionGo"
/>
<EditText android:id="@+id/googlebar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft ="1.5px"
android:layout_marginRight ="3px"
android:background="@android:drawable/editbox_background"
android:layout_weight="0.65"
android:hint="Google"
android:textSize = "15sp"
android:singleLine="true"
android:ellipsize="end"
android:imeOptions="actionSearch"
/>
</LinearLayout>
你觉得怎么样?
I have 2 EditTexts in a linear layout and they don't get ellipsized
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#696969"
android:layout_marginBottom ="5px">
<EditText
android:id="@+id/addressbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft ="2px"
android:layout_marginRight ="1.5px"
android:layout_weight="0.35"
android:textSize = "15sp"
android:singleLine="true"
android:editable = "true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="end"
android:imeOptions="actionGo"
/>
<EditText android:id="@+id/googlebar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft ="1.5px"
android:layout_marginRight ="3px"
android:background="@android:drawable/editbox_background"
android:layout_weight="0.65"
android:hint="Google"
android:textSize = "15sp"
android:singleLine="true"
android:ellipsize="end"
android:imeOptions="actionSearch"
/>
</LinearLayout>
what do you think?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
设置此属性以编辑文本。 Elipsize 正在使用禁用编辑文本
或
setKeyListener(空);
这对我来说在所有 Android 平台上都很好用。
Set this property to edit text. Elipsize is working with disable edit text
or
setKeyListener(null);
This work for me fine in all Android platforms.
我可以看到很多人的评论说 Ellipsize 在 TextView 中工作得很好。但在 EditText 中不行!实际上我想说我们需要深入研究 EditText。因为 EditText 是 TextView 的子级。 EditText 能够获取用户的输入,这在 TextView 上不可用。所以EditText有KeyListener来观察EditText输入按键事件变化。当您添加椭圆时,我们必须禁用此功能。因此您的 EditText 不会每次都刷新,并且您不会失去椭圆功能。
I could see comment from many people that is Ellipsize works fine in TextView. But not in EditText! Actually I would say we need to have deep look at the EditText. Because EditText is child of TextView. EditText has capability to get input from user, which doesn't available on TextView. So EditText has KeyListener to observe EditText input key event changes. We have to disable this while you add ellipsize. So Your EditText won't be refreshed every time and you will not lose ellipsize feature.
Ellipsize 已损坏: Ellipsize 不适用于自定义 listView 内的 textView
错误报告:http://code.google.com/p/android /issues/detail?id=882
我必须执行以下操作才能让我的工作正常运行...花了一些时间
Ellipsize is broken: Ellipsize not working for textView inside custom listView
Bug Report: http://code.google.com/p/android/issues/detail?id=882
I had to do the following to get mine working...took a bit of fiddling
我有一个解决方案,将此行添加到您的 EditText
机器人:可编辑=“假”
edittext 将被省略,但此属性已被弃用,但如果它没有被弃用,当此 edittext 不可编辑时,我不知道如何通过 java 编码使其再次可编辑。
I have a solution, add this line to your EditText
android:editable="false"
The edittext will be ellipsized, but this property is deprecated, but event it's not deprecated, when this edittext is uneditable I don't know how to make it be editable again by java coding.
试试这个,
android:editable="false"
或setKeyListener(null)
参考:禁用时省略 editText 的内容
Try this,
android:editable="false"
orsetKeyListener(null)
Reference: Ellipsize content of editText when disabled