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?
Set this property to edit text. Elipsize is working with disable edit text
android:lines="1"
android:scrollHorizontally="true"
android:ellipsize="end"
android:singleLine="true"
android:editable="false"
or setKeyListener(null); This work for me fine in all Android platforms.
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.
editText.setKeyListener(null);
editText.setEllipsize(TextUtils.TruncateAt.END);
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
android:lines="1"
android:scrollHorizontally="true"
android:ellipsize="end"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With