Hide softkeys in Android and do not show even when user interacts during app.

Note. Please do not close this question as a duplicate, as the other answers only hide the function key bar [navigation bar at the bottom with three control buttons] until there is user interaction.

Hi, I am developing a paint application where the user can paint just like in MS-paint.

In order to use the full space of the custom screen, I want to hide the function key bar when the user draws or draws something.

So I know how to hide the softkey bar, but on user interaction [any interaction], the softkey bar appears on the screen. [Before the lollipop]

Is there a way to hide the softkey bar and they only appear after the user exits the application. [I think I've seen this in some games]

Note: It was also stated somewhere that the OS shows the softkey bar so some goofy app doesn't ruin the UI.

Any guidance would be greatly appreciated.

Update: 1. This is the link I used earlier: How to hide the soft keys bar on Android phone?

  1. In the softkey bar, I mean the navigation bar at the bottom of the screen, as shown in the question in point 1.

Thank.

+3


source to share


3 answers


Hide keyboard with InputMethodManager and set EditText Focusable to False Will do the trick. Below code will hide the keyboard and set the EditText to False.

 editText1.setFocusable(false);
 InputMethodManager imm = (InputMethodManager)getSystemService(
                              Context.INPUT_METHOD_SERVICE);
 imm.hideSoftInputFromWindow(editText1.getWindowToken(), 0);

      



To edit EditText again use

editText1.setFocusableInTouchMode(true);
editText1.setFocusable(true);

      

0


source


1) Do this for ur activity in manifest where you don't want to see android keyboard:

android:windowSoftInputMode="stateAlwaysHidden|adjustResize" 
android:configChanges="orientation|keyboardHidden"

      

2) Override these Android method callbacks for views that have click and focus listeners (like edit texts):



public void onFocusChange(View v, boolean hasFocus)
public boolean onTouch(View v, MotionEvent event)
public void onClick(View v)


if(!hasFocus) {
InputMethodManager imm =  (InputMethodManager)  getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}

      

the above focus check is done in focus change and onclick mode and calls view.perform () on onTouch.

thats it..u can hide at any time.

0


source


 public void hideSoftKeyboard() {
    if (getCurrentFocus() != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    }
}

      

Use this method to hide the keyboard with focus.

0


source







All Articles