android - callback method for soft keyboard changes? -
is there callback methods soft keyboard , down. want action when soft keyboard , down. know check whether keyboard or down. should call method somewhere. here don't want call it. should triggered automatically when there change in soft keyboard state.
try code worked in project
r.id.activityroot
parentlayout id
final view activityrootview = findviewbyid(r.id.activityroot); activityrootview.getviewtreeobserver().addongloballayoutlistener( new ongloballayoutlistener() { @override public void ongloballayout() { try { int heightdiff = activityrootview.getrootview() .getheight() - activityrootview.getheight(); if (heightdiff > 100) { // if more 100 pixels, // // keyboard... //do stuff here keyboard shown }else { //do stuff here keyboard not visible } } catch (nullpointerexception e) { e.printstacktrace(); } catch (exception e) { e.printstacktrace(); } } });
Comments
Post a Comment