Why edit text is underlined? - android

EditText is disabled, but still it is underlined. Why, how can I remove underline? What exactly underline means? In iOS same component is UITextView but it never underline so the control.
<EditText
android:layout_width="305dp"
android:layout_height="79dp"
android:inputType="textMultiLine"
android:ems="10"
android:layout_below="#+id/view"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp"
android:id="#+id/editText5"
android:text="Do you know y.."
android:enabled="false" />

EditText is disabled
Use a TextView instead.
how can I remove underline?
Use a TextView instead.
Or, use a different background for the EditText, probably. I assume that the Theme.Material/Theme.AppCompat way of supplying that bracket is via the background, as it was with Theme and Theme.Holo. I have not changed the background of an EditText in years, as usually it is not needed.
What exactly underline means?
It tells humans that this represents text that they can edit, as opposed to text that they cannot edit.

Related

The last character of Button's text is partially visible

I have a FrameLayout which contains an EditText and a Button.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/edittext_hint"
android:inputType="textPassword"
android:maxLength="25" />
<Button
android:id="#+id/forgottenPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:background="#null"
android:fontFamily="#font/sf_pro_display_lightitalic"
android:padding="16dp"
android:marginRight="16dp" // still, it gets cropped
android:text="#string/password_button"
android:textSize="18sp" />
</FrameLayout>
I gave padding=16dp to the Button but somehow the question mark is partially visible. If I make the phrase short like "Forgot it?" then the '?' mark fully visible. I didn't understand. I gave it even marginRight=16dp, still...
But when I don't set fontFamily attribute, again it is fully visible.
The confusion I have is that how come the last character gets cropped even though it has padding and marginRight. I even tried adding space after the question mark but nothing changed. Am I missing something?
Edit: I am actually using strings.xml for the button's text. When I add space after the '?' in the strings.xml it doesn't effect the text in the button, however, when text is hard coded and added space after the '?', question mark is fully visible again. But as it is said over and over Hardcoded string is bad.
I can't make my phrase short like "Forgot it?", because the app is in Turkish and the original phrase is relatively long. And also I have to use that font.
That is because your font is italic. If you want to insert a space character in XML file use   after ? like this : ? .
That's because of the padding on your button. Remove the padding and try it out.
If all you want is some clickable text, there's no need for a Button:
<TextView
android:id="#+id/forgottenPassword"
android:clickable="true"
android:focusable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:fontFamily="#font/sf_pro_display_lightitalic"
android:padding="16dp"
android:marginRight="16dp"
android:text="#string/password_button"
android:textSize="18sp" />
Notice that I added clickable and focusable.

Android studio editText turns uneditable when selectable

I have an EditText which I want to be editable and selectable, just like any other EditText. My theme is
...Light.NoActionBar
so I need an extra ActionBar for the Copy/Paste etc. when the text is selected.
So I use
editText.setTextIsSelectable()
and it works, but when I enable it, the textView becomes ineditable!
To make it editable again, I use the following
editText.setFocusableInTouchMode(true);
editText.setFocusable(true);
editText.setClickable(true);
editText.setLongClickable(true);
but it doesn't help! Also, it doesn't make a difference whether I assign these tags in the .xml or in the code, I tried that...
I guess the solution is pretty simple, but the API docs and google didn't tell me how to make it editable again... It seems like noone ever had that problem before
EDIT:
xml:
<EditText
android:id="#+id/etMitspieler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="Players"
android:inputType="textPersonName"
android:text="test"
android:textColor="#android:color/background_light"
some constraint stuff... />

Text input is white

One of the users of my app is having an issue where the text he enters in the EditText elements of my app is white, which effectively renders it invisible against a white background. He's the only user experiencing this issue, and it's only happening to him in my app.
As an example, here's the code for one of my EditText elements:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/usernameTextBox"
android:imeOptions="actionDone"
android:singleLine="true"/>
There are dozens of these in my app, and all are essentially coded the same. Any ideas why this might be happening?
Every android distribution can overwrite default colors for widget. Therefore, if you want all of your EditText to look the same you should explicitly set their background and text color like so:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/usernameTextBox"
android:imeOptions="actionDone"
android:singleLine="true"
android:background="#FFFFFF"
android:textColor="#000000"/>
To ensure that the text colour being displayed correctly, strictly set the textColor attribute for each declared TextView like so android:textColor="#android:color/black"

Remove the underline from edittext in android

I am using a edittext with multiline property.when i type any word there is no underline but as i used space or enter key all the text cover by underline .how it can be remove . I dont want to see underline .so please give me any solution..
my xml file is......
<EditText
android:layout_centerInParent="true"
android:id="#+id/etext"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:visibility="invisible"
android:textSize="20dp"
android:background="#null"/>
I suppose you mean underlines that come with auto-suggestions.
If you don't want them, try this
android:inputType="textNoSuggestions"
in your EditText xml.

How to remove the underline from the EditText field in Android?

Whenever a word is typed in the EditText box, I always see an underline under the word being typed. But when I press a space after that word I no longer see the underline.
My reqirement is to remove that underline when the user is typing the message.
Added is the screenshot and we see that Smith is underlined. But I don't want this to happen.
Below is the xml that I use for the AlertDialog box.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/name_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="#string/alert_dialog_name"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/username_edit"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:inputType="textPersonName"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
android:inputType="textNoSuggestions"
There is a function that removes any composing state. I think if you call it after every time a user types, you will not see the underline. I use it after the user finishes typing, to get the drawing cache of the entire textView (which I need without underline). It's
someTextView.clearComposingText();
You don't have to use any logic to remove the underlines -- just call getText().toString() when you want to use the value. It won't include special formatting or anything.
accepted answer is not given solution, and some other user given answer but no one given full anser, so that's why i write here working solution.
If you want to remove underline then just add below code.
XML
android:inputType="textNoSuggestions"
Java
EditText ed;
ed = findViewById(yourId);
ed.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
If you want to set more than one input type then,
ed.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
May be above information is helpful to others.
The best solution for this is to add on your EditText:
android:inputType="textMultiLine|textVisiblePassword"
Use this from your class, if EditText view is dynamic (created from class file):
EditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
OR include android:inputType="textNoSuggestions" with your EditText in XML.
Read this if you want to keep emojis and textNoSuggestions doesn't work for you.
textNoSuggestions does not work in every keyboard.
inputType="textVisiblePassword" works but it removes emoji's from most keyboards.
I found that setting inputType="textUri" works and keeps the ability to add emojis.
try:
android:inputType= InputTypes.TextVariationVisiblePassword;
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:imeOptions="actionDone"
android:inputType="textNoSuggestions"
android:maxLines="1"
/>

Categories

Resources