Automatically eject the soft keyboard
editText = (EditText) findViewById(R.id.edit_text); editText.setFocusable(true); editText.setFocusableInTouchMode(true); editText.requestFocus(); InputMethodManager imm = imm.showSoftInput( edtsearch_title, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
Turn off the soft keyboard
Method1: ((Inputmethodmanager) Getsystemservice (Input_method_service)). Hidesoftinputfromwindow(Getcurrentfocus (). Getwindowtoken(), Inputmethodmanager. HIDE_not_always);Method2: Inputmethodmanager IMM = (inputmethodmanager) view. GetContext(). Getsystemservice(Context. INPUT_method_service);if (IMM. IsActive()) {IMM. Hidesoftinputfromwindow(View. Getapplicationwindowtoken(),0);
How to get the height of a soft keyboard
FinalRelativelayout mylayout = (relativelayout) Findviewbyid (R.id.rootview); Mylayout.getviewtreeobserver (). Addongloballayoutlistener (NewViewtreeobserver.ongloballayoutlistener () {/** * The result is pixels */ @Override Public void Ongloballayout() {Rect r =NewRect (); Mylayout.getwindowvisibledisplayframe (R);intScreenHeight = Mylayout.getrootview (). GetHeight ();intHeightdifference = ScreenHeight-(r.bottom-r.top); LOG.E ("Keyboard Size","Size:"+ heightdifference);//boolean Visible = heightdiff > Screenheight/3;} });
Reference
Http://stackoverflow.com/questions/13534365/getting-the-dimensions-of-the-soft-keyboard
Http://stackoverflow.com/questions/18435112/how-to-get-android-soft-keyboard-height
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android cultivation path-get the height of the soft keyboard