Search code examples
androidtextvieweditview

android editview as textview and many lines in one textview


Is there any way to make EditView to work sometimes as itself and sometimes as TextView (readonly, but not grayed (when I set setEnabled(false) it becomes gray which I dont like). Simply I would like to use the same form for displaying information and for editing and as for now the only solution which comes to my mind is to have two components and to play with visibility parameter of them (sometimes EditView is visible and TextView not and vice versa).

And is there any possibility to have few lines in one TextView? When I wrote

android:text="bla bla \n bla bla"

in xml code it doesn't work. :(


Solution

  • You can set text color to black or any other you want in disabled mode using android:textColor="#000000" in you xml. But if you also want EditText to hide its style and totally look like TextView, you will need to apply custom styling on your text view for this...which will unnecessarily increase you efforts.

    Proffered and most robust way is to have two views i.e. TextView and EditText togather and play with their visibility.

    And in your second part of question, text should go to next line ideally, if its not, then there might be some other property which is restricting it to do so...