Screen mode, even if the activity's Windowsoftinputmode property is set to: adjustresize, it does not push the activity's screen upward while the keyboard is displayed, So the size of the root tree of your activity's view is unchanged. In this case, you will not know the size of the keyboard, the root view of the corresponding changes. The problem that the keyboard can't resize in full screen has existed since 2.1, and Google hasn't solved it yet.
The following classes can be used to solve this problem:
Public classAndroidbug5497workaround {//For more information, seehttps://code.google.com/p/android/issues/detail?id=5497 //to use the This class, the simply Invoke Assistactivity () on the Activity that already have its content view set. Public Static voidassistactivity (activity activity) {NewAndroidbug5497workaround (activity); } PrivateView mchildofcontent; Private intusableheightprevious; PrivateFramelayout.layoutparams Framelayoutparams; PrivateAndroidbug5497workaround (activity activity) {Framelayout content=(framelayout) Activity.findviewbyid (Android. R.id.content); Mchildofcontent= Content.getchildat (0); Mchildofcontent.getviewtreeobserver (). Addongloballayoutlistener (NewViewtreeobserver.ongloballayoutlistener () { Public voidongloballayout () {possiblyresizechildofcontent (); } }); Framelayoutparams=(Framelayout.layoutparams) mchildofcontent.getlayoutparams (); } Private voidpossiblyresizechildofcontent () {intUsableheightnow =computeusableheight (); if(Usableheightnow! =usableheightprevious) { intUsableheightsanskeyboard =Mchildofcontent.getrootview (). GetHeight (); intHeightdifference = Usableheightsanskeyboard-Usableheightnow; if(Heightdifference > (USABLEHEIGHTSANSKEYBOARD/4)) { //keyboard probably just became visibleFramelayoutparams.height = Usableheightsanskeyboard-heightdifference; } Else { //keyboard probably just became hiddenFramelayoutparams.height =Usableheightsanskeyboard; } mchildofcontent.requestlayout (); Usableheightprevious=Usableheightnow; } } Private intcomputeusableheight () {Rect R=NewRect (); Mchildofcontent.getwindowvisibledisplayframe (R); return(R.bottom-r.top); }}
How to use: Call Androidbug5497workaround.assistactivity (this) in your activity's OnCreate () method; Note: Called after Setcontentview (r.layout.xxx).
Android adjustresize Full Screen Invalid issue