Android - Hidden but Select-able EditText - java

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.

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"

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>

Set transparent Background to EditText.
android:background="#00000000"
Sorry but I didn't understand your another question.

Related

Can't focus on EditText after setting focus to true

Im having trouble undestanding what is happening here.
If I don't mess with "setFocusable" on EditText it works like I excpect (when you click on it the keyboard pops up and you can edit it as normal), if I set it to true it also works like before:
holder.editTextExercise.setFocusable(true);
But if I set it to false, and than back to true, I can no longer see a keyboard pop up, so I can't edit it
holder.editTextExercise.setFocusable(false);
holder.editTextExercise.setFocusable(true);
Here is the EditText
<EditText
android:id="#+id/recyclerExercise"
android:layout_width="0sp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textColor="#color/grey"
android:backgroundTint="#color/grey"
android:text="#string/app_name"
android:textSize="25sp"/>
Im putting different items with EditTexts in the recycler and sometimes I want to change them so they can/can't be editable.
What is going on here?
Instead of
holder.editTextExercise.setFocusable(false);
holder.editTextExercise.setFocusable(true);
Try
holder.editTextExercise.setEnabled(false);
holder.editTextExercise.setEnabled(true);

Cannot get editText to do a line break from enter (android)

So i have multiple edittext's in one constraint layout and i cannot get my multiline edittext to do a linebreak from enter, i have tried settings imeOptions to normal, actionUnspecified, actionNone and actionDone and no luck, it does not do a line break. Could not find anyone with this issue, only opposite =)
What am i doing wrong? here is the code for my edittext
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="text|textImeMultiLine|textCapSentences"
android:ems="10"
android:singleLine="false"/>
have you tried android:maxLines, like android:maxLines="10"?

How to adjust keyboard foucus layout on Android?

This is my keyboard zoomin view when i click the edit text.
Problem is:
It is way too big only one small strip of edit text is enough.
Keyboard sometimes floating sometimes docking dont know what controls it.
No need of that finish button and green line
What is the callback function once the input in done
This is the method request soft keyboard popup
public void editText(){
Toast.makeText(mContext, "Editing Text",Toast.LENGTH_SHORT).show();
InputMethodManager imm = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
mEditText.setVisibility(VISIBLE);
mEditText.requestFocus();
mEditText.setText(mText);
imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
}
Properties of edit text
<EditText
android:id="#+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:hint="annotation text"
android:inputType="text"
android:textSize="14sp"
android:visibility="gone"/>
It a default layout when you change your device orientation to landscape.
Add
android:imeOptions="flagNoExtractUi|flagNoFullscreen"
to disable the fullscreen editing view
<EditText
android:id="#+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:imeOptions="flagNoExtractUi|flagNoFullscreen"
android:hint="annotation text"
android:inputType="text"
android:textSize="14sp"/>
flagNoExtractUi Used to specify that the IME does not need to show its extracted text UI. For input methods that may be fullscreen,
often when in landscape mode, this allows them to be smaller and let
part of the application be shown behind. Though there will likely be
limited access to the application available from the user, it can make
the experience of a (mostly) fullscreen IME less jarring. Note that
when this flag is specified the IME may not be set up to be able to
display text, so it should only be used in situations where this is
not needed.
flagNoFullscreen Used to request that the IME never go into fullscreen mode. Applications need to be aware that the flag is not a
guarantee, and not all IMEs will respect it.

Creating a button from an event for android

I have looked for ways to make a button/layoutchange that appears depending on the choice made by the user. It is a dice simulator so if you pick you need a 4 sided die or 6 sided die a different look will pop out. I am looking to get some directions. Should I premake them in html or java? Or should I use another approach? The decision of how many sides gets asked through an alertdialog. Thank you for any help.
If you want to change layout dynamically you can use generic View to hold the space and inflate appropriate layout into them.
http://developer.android.com/reference/android/view/LayoutInflater.html
You can place the button, that should appear in your XML-layout-file and set its visibility attribute to gone. Like so:
<Button
android:id="#+id/button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:visibility="gone"
/>
Then you could change the visibility programmatically (for example in the OnTouchListener of another button or so).
//retrieve the button created in the xml-layout by its id
mButton= (Button) findViewById(R.id.button_1);
//change its visibility
mButton.setVisibility(View.VISIBLE);
mButton.setVisibility(View.GONE);
I hope, I could help you.
Best regards,
G_J

How can I place an EditText and TextView in a RadioButton?

I have a RadioGroup inside of a RelativeLayout. I've got a few RadioButtons for different options, like "Bob", "Joe", and "Fred". However, I need to add an "Other..." option with an EditText right next to a RadioButton in case a user wants to enter "Steve". Is there a way to do this?
Just one idea that comes to mind is to use android:layout_marginLeft and android:layout_marginTop tags to position the EditText field where you need it to be. Be sure to use dip to support multiple densities across devices.
<EditText
android:layout_marginLeft="65dip"
android:layout_marginTop="100dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="" />
Then, if the user selects your Other radio button, just grab the value from EditText.

Categories