Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Hidden but Select-able EditText

I would like to have a EditText in my Android app that you can not see, however you can select and type text into. In other words I would like it so that it can not be seen at all however other than that it behaves completely normally.

Another option is to have an image or button on the screen which the user presses to enter text into the EditText which is hidden behind another EditText.

Thanks for the help, however it is looking more likely that I will have to use the second option. To elaborate on it, for example I have a TextView that says 'Welcome'. I would like the user to be able to click on this text to bring up the keyboard and edit in the EditText field. The reason for having the EditText field hidden behind another is to cover up the cursor while making it seem the user is typing the text which appears on the screen.

like image 283
Nic Steyn Avatar asked Oct 29 '25 10:10

Nic Steyn


2 Answers

If you would like to make the EditText fully invisible (even what the user types in) , but still be able to retrieve the entered data through myEditText.getText().toString(),

you could add:

android:textColor="@android:color/transparent"
android:background="#00000000"
android:cursorVisible="false"
like image 149
Daniel Montoya Avatar answered Oct 30 '25 23:10

Daniel Montoya


if I'm getting you correctly. Here is how you can accomplish the first option of yours by setting the background to transparent and cursor visibility to false.

To check this you have to click at the center of screen.

e.g. code snippet:

<EditText
    android:id="@+id/eT1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:background="#00000000"
    android:cursorVisible="false"
    android:ems="10" >


</EditText>
like image 32
Mohit Avatar answered Oct 31 '25 00:10

Mohit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!