How can i remove the extra space above the keyboard? - android

I have one activity an in this activity i have one BottomSheet.
In the bottomsheet layout there is button below the editext .
when keyboard is opened then in that case button is hiding behind the keyboard . and when i scroll then the button is visible. what i want is that the button should be always above the keyboard

This is the autocomplete suggestion area of your softkeyboard. Use "textNoSuggestions" flag to your inputType property.
<EditText android:id="#+id/inputName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions"
android:hint="#string/inputName" />
Note: Here you can combine multiple flags in inputType like this,
android:inputType="textPersonName|textNoSuggestions"
Just add |textNoSuggestions flag to the end of the inputType property.

Add this line in to your Edittext
android:inputType="textNoSuggestions"

Related

Android - How to disable the paste suggestion on top of the soft keyboard

I want to disable the paste suggestion on the soft keyboard in the EditText XML or programmatically.
The thing I'm referring to is the button with "563737" below
To disable the paste suggestion feature on the on-screen keyboard for an EditText element, you can specify the "textNoSuggestions" value for the "android:inputType" attribute in the EditText's XML definition.
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions" />
Or you can set the inputType property programmatically in code:
EditText editText = findViewById(R.id.edit_text);
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Strange behaviour of edittext when receiving focus

I have 2 layouts with EditText widget in them. In the first one EditText automatically receives focus on activity's start but shows no software keyboard (this is the desired behaviour). In the second layout, however, EditText is focused and shows soft-keyboard. I examined both layouts and can't find a reason for this behavour, because both widgets have identical properties. Soft-keyboard should only be displayed when I touch the input field. Am I missing something?
<EditText
android:id="#+id/scanLine"
android:layout_width="253.0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="19.0dp"
android:imeOptions="actionDone"
android:singleLine="true"
android:inputType="text"
android:maxLines="1"
android:focusableInTouchMode="true" />
Add the following line to the onCreate() method of your activity:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Hope it helps!

How to prevent soft keyboard from appearing on touch

I don't want the soft keyboard to appear when a particular EditText is touched. But I still want to be able to show the soft keyboard upon user request (say, when a button is pressed) and allow the user to edit the text.
I know how to show/hide the soft keyboard, I only don't know how to prevent it from appearing on touch.
Any suggestion how to do it?
The general idea is that the user will be mostly working with selection/position within the text, and only occasionaly entering characters.
I don't want the visible amount of text to be reduced by the soft keyboard when selecting or navigating the text.
simply use
txtEdit.setShowSoftInputOnFocus(false);
and when you want to enable that , reverse above process
This works:
editText.setShowSoftInputOnFocus(false);
within the activity in the manifest add the below code
android:windowSoftInputMode="adjustPan"
AndroidManifest.xml windowSoftInputMode
<activity android:name=".MyActivity" android:windowSoftInputMode="adjustPan"> </activity>
Try the below code, it hides the keyboard:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
Why don't you disable the edittext. Then it will not show keyboard on click. To this you can:
android:editable="false" //from xml
et.setEnabled(false); //from activity
And then on your buttonClick make it enable by setting above code true. And make your keyboard appear.
Also If you don't get the focus on edittext you can:
et.requestFocus(); // from activity
<EditText
android:id="#+id/et1"
android:editable="false"
android:layout_width="150dp"
android:layout_height="wrap_content" >
<requestFocus/>
</EditText>
//from xml
Hope this helps!

How do I show the Phone Input softkeyboard when my activity starts?

Between the Activity tags in my AndroidManifest.xml I have :
android:windowSoftInputMode = "stateVisible"
So when my activity starts the soft keyboard comes up:
Is there not something I can add to make the phone input keyboard come up instead? Or how would I do it? Thanks.
EDIT
For the sake of clarity to this question I'm adding this 'edit'.
First of all, thanks for all the answers below.
However, my objective is to have no Edittext Visible on the screen, at first. The Phone Input soft keyboard comes up as soon as the activity starts and when the user starts
to type then the Edittext will become visible, with the text being typed.
I tried making the Edittext invisible, and then make it visible when user starts typing, but the problem is an invisible edittext can't have the focus,
So, android:inputType="number" was having no effect. And neither was: edittext.requestFocus(); Because the edittext was invisible.
What I ended up doing eventually was something very simple, setting width and height to 0dp in my xml like :
android:id="#+id/etPhoneNumber"
android:layout_width="0dp"
android:layout_height="0dp"
android:inputType="number" />
That way, the edittext can get focus with
edittext.requestFocus();
as soon as the activity is created, and inputType = "number" is recognised.
The next thing I'll do is increase the size of the edittext as soon as a key is hit on the soft keyboard, so users can see it.
I'll put all this in as an answer so it might be helpful to other users. +1 for the help!
Assuming that you have an EditText in the Activity which you show once your app is started, you can add below XML Attribute to your EditText.
android:inputType="phone"
Check developer docs for other input types in case if you need.
You can add
android:inputType="phone"
or
android:inputType="number"
to your View in your XML layout.
You should have some View in your code where you can give input like EditText or AutoCompleteTextView for changing the type of the keypad.
For example -
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:inputType="phone"
/>
In manifest file set the property in activity,
android:windowSoftInputMode="stateAlwaysVisible"
and then in your xml where your EditText set the property,
android:inputType="number"
first of all take an EditText in your xml
<EditText
android:id="#+id/etPhoneNumber"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="number" />
use this piece of code in the onCreate method of your activity !
EditText etPhoneNumber = (EditText) findViewById(R.id.etPhoneNumber);
etPhoneNumber.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
This works for me very well ! Hope it works for you too !
Let me know if this works ! :)
The objective is to have no Edittext Visible on the screen, at first.
The Phone Input soft keyboard comes up as soon as the activity starts and when the user starts
to type then the Edittext will become visible, with the text being typed.
I tried making the Edittext invisible, and then make it visible when user starts typing, but the problem is an invisible edittext can't have the focus,
So, android:inputType="number" was having no effect. And neither was: edittext.requestFocus(); Because the edittext was invisible.
What I ended up doing eventually was something very simple, setting width and height to 0dp in my xml like :
android:id="#+id/etPhoneNumber"
android:layout_width="0dp"
android:layout_height="0dp"
android:inputType="number" />
That way, the edittext can get focus with
edittext.requestFocus();
as soon as the activity is created, and inputType = "number" is recognised.
The next thing to do now is increase the size of the edittext as soon as a key is hit on the soft keyboard, so users can see it.

Keyboard over EditText on second click

This is the picture:
When I click on the "Confirm password" EditText, for the first time, it works the way it should - layout pops up so I can enter text in selected EditText, but when I dismiss keyboard(that EditText still focused) and click on that same EditText again, it stays under keyboard.
Main layout is RelativeLayout, input fields are in ScrollView and buttons are in LinearLayout aligned to parent bottom.
In manifest I have android:windowSoftInputMode="adjustPan".
Is this some Android issue or I've been doing something wrong?
It's actually a bug in EditText. try removing gravity of EditText, which could be either center_horizontal or center
Got the answer from another question. check this.
For me removing android:minWidth does the trick
I just came with a workaround for this problem as well, I got my edit text to start the text in the middle of the screen with a not so great solution, but it works for me. The code is this one:
<EditText
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingStart="130sp"
android:paddingEnd="50sp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:gravity="bottom"/>

Categories

Resources