Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove underlying line when editing specific word in edit Text View

this is what I tried and nothing works looked everywhere but found nothing

str.setTypeface(notoKyfiBold);
str.setText("دوس هنا للكتابه");
str.setTextColor(Color.BLACK);
str.setGravity(Gravity.CENTER);
str.setFocusable(false);
str.setFocusableInTouchMode(false);
str.setCursorVisible(false);
str.setClickable(false);
str.setMaxLines(15);
str.setEnabled(false);
str.setActivated(false);
str.setSingleLine(false);
str.setMaxTextSize(50);
str.setKeyListener(null);
str.setMinTextSize(0);
str.setHintTextColor(Color.TRANSPARENT);
str.setBackground(null);
str.setBackgroundColor(Color.TRANSPARENT);
str.setSizeToFit(true);
str.setPadding(10,0,10,0);
str.endBatchEdit();
str.setDrawingCacheBackgroundColor(Color.TRANSPARENT);
str.getPaint().setStrokeWidth(4);
str.setHighlightColor(Color.TRANSPARENT);
str.getPaint().setStyle(Paint.Style.STROKE);

the line is the one directly below the text, not that bottom border:

image

like image 876
Mahmoud Elfeel Avatar asked Jan 06 '23 01:01

Mahmoud Elfeel


2 Answers

If you want to do it programmatically, then you can use the following code.

//assume an EditText object with name myEditText
myEditText.setInputType(myEditText.getInputType() | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS does not seem to work as expected on all keyboards whereas InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD has the drawback that it also disables toggling the language in the keyboard and the swipe gesture to add the text.

like image 65
Varun Bhatia Avatar answered Feb 10 '23 02:02

Varun Bhatia


Just add following attribute in your edittext block in xml file:

android:inputType="textNoSuggestions"
like image 36
Satish Silveri Avatar answered Feb 10 '23 03:02

Satish Silveri