android - How to listen SoftInputMethod's show/hide event? -
i try implement using broadcastreceiver in way. not work.the show/hide event never come receiver.
filter = new intentfilter(); filter.addaction(intent.action_input_method_changed); filter.setpriority(intentfilter.system_high_priority); registerreceiver(receiver, filter);
i hope nice man can me.
that's all
hope it's you.
ongloballayoutlistener mongloballayoutlistener; private void performlistenkeyboard() { if (mongloballayoutlistener == null) { mongloballayoutlistener = new viewtreeobserver.ongloballayoutlistener() { @override public void ongloballayout() { final int screenheight = mrootview.getrootview().getheight(); int keyboardheight = screenheight - mrootview.getheight(); if (keyboardheight < screenheight / 3 || !isshowkeyboard) { return; } // keyboard show,do // @ last , remove listener mrootview.getrootview().getviewtreeobserver().removeongloballayoutlistener(mongloballayoutlistener); } }; } // register globallayoutlistener callback mrootview.getrootview().getviewtreeobserver() .addongloballayoutlistener(mongloballayoutlistener); }
Comments
Post a Comment