0

Is there any way to make the EditText as partially non editable with some background color. Something like below image...

enter image description here

Here the light dark texts are non editable and others are editable.

I have tried with TextWatcher like below by the help of some text spiting regex (split("\\.")) .

@Override
public void afterTextChanged(Editable s) {
    // TODO Auto-generated method stub
     if(!s.toString().startsWith(firstSentense)){
         fullStory.setText(firstSentense+".");
         fullStory.setTextColor(Color.parseColor("#60000000"));
         Selection.setSelection(fullStory.getText(), fullStory.getText().length());

     }
}

But unfortunately I can't able to show the background for non editable texts. And when I'm trying to move the marker to the end of non editable stuffs, it deletes the total editable texts.

Can anyone faced and resolved this type of stuffs.

arodriguezdonaire
  • 5,396
  • 1
  • 26
  • 50
Ranjit
  • 5,130
  • 3
  • 30
  • 66
  • this post might help you http://stackoverflow.com/questions/14195207/put-constant-text-inside-edittext-which-should-be-non-editable-android – rogerwar Aug 06 '15 at 09:41

1 Answers1

0

There's an open source library that is similar to what you want to achieve.

Parked TextView

Its basically an EditText but some text is always constant in that. So some text is editable and other is not editable. But constant text is always at the end. You can view the code and change it how you want it to be.I hope my answer is useful.

Community
  • 1
  • 1
Noman Rafique
  • 3,735
  • 26
  • 29