3

Note: Please don't close this question as duplicate as the other answers only hide the softkey bar [navigation bar at the bottom with 3 control buttons] till the user interaction is not there.

Hi, I am developing a paint app in which the user can draw similarly as in MS-paint.

To use the full estate of user's screen, I wish to hide the softkeys bar while the user is drawing or painting anything.

So, I know how to hide the soft-keys bar but on user interaction [on Any interaction] the soft-keys bar appear on the screen. [Before lollipop]

Is there any way that I can hide the soft-keys bar and they only appear after the user has exited from the app. [I think I have seen this happening in some of the games]

Note: somewhere it was also stated that the OS shows the soft-keys bar so that some goofy app doesn't ruin user's experience.

Any lead will be appreciated.

Updates: 1. This is the link that I had followed earlier: How to hide the soft-key bar on Android phone?

  1. By soft-keys bar I mean the navigation bar at the bottom of the screen as shown in the question in point 1.

Thanks.

Community
  • 1
  • 1
Bhanu Pratap Singh
  • 1,017
  • 1
  • 12
  • 15
  • when it is opening ?? – Ankit Kumar Apr 29 '15 at 13:05
  • @AnkitKumar Sorry, but haven't understood your question properly. If you are asking that when does the soft-keys open, the answer is any user interaction. Even if I touch the screen, the soft-keys will come on the screen and the app's estate decreases. I have also updated the question. Please check. – Bhanu Pratap Singh Apr 29 '15 at 13:15
  • have you solved this problem? – SatZ Jun 14 '16 at 11:55

3 Answers3

0

Hide The Keyboard with InputMethodManager and Set EditText Focusable False Will do the trick. Below code will hide the Keyboard and set EditText focusable as False.

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

To Make EditText Editable Again, Use

editText1.setFocusableInTouchMode(true);
editText1.setFocusable(true);
Dhaval Patel
  • 10,119
  • 5
  • 43
  • 46
0

1) Do this for ur activity in Manifest where u don't want to see Android Keypad:

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

2) Override these method call backs of Android for views that has on click and on 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 u do in focus change method and onclick, and call view.perform() in onTouch.

thats it..u can hide at all time.

DJphy
  • 1,292
  • 1
  • 17
  • 31
  • Hi, I updated the question, basically I wish to hide the navigation bar at the bottom of the screen. Can you suggest something for that ? – Bhanu Pratap Singh Apr 30 '15 at 06:50
  • Surely, i too need to workaround to "hide the navigation bar at the bottom of the screen".. – DJphy Apr 30 '15 at 06:54
0
 public void hideSoftKeyboard() {
    if (getCurrentFocus() != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    }
}

Use this method to hide keyboard it has focus.

Ankit Kumar
  • 3,663
  • 2
  • 26
  • 38