Private voidControlkeyboardlayout (FinalView Root,FinalView Scrolltoview) {Root.getviewtreeobserver (). Addongloballayoutlistener (NewOngloballayoutlistener () {@Override Public voidongloballayout () {rect rect=NewRect (); //get root in the visible area of the formroot.getwindowvisibledisplayframe (rect); //gets the non-viewport height of the root in the form (the height of the area being obscured by other view) intRootinvisibleheight = Root.getrootview (). GetHeight ()-Rect.bottom; //if the visible area height is greater than 100, the keyboard displays if(Rootinvisibleheight > $) { int[] location =New int[2]; //gets the coordinates of the Scrolltoview in the formScrolltoview.getlocationinwindow (location); //calculates the root scroll height so that the scrolltoview in the visible area intSrollheight = (Location[1] + scrolltoview.getheight ())-Rect.bottom; Root.scrollto (0, Srollheight); } Else { //Keyboard HideRoot.scrollto (0, 0); } } }); }
Red numerals can be adjusted appropriately
Reference
Getlocationinwindow
The coordinate position of a control in its parent window
Getlocationonscreen
The coordinate position of a control on its entire screen
http://blog.csdn.net/chengyingzhilian/article/details/7452082
http://blog.csdn.net/fuuckwtu/article/details/6519689
Android Keyboard masking parent layout roll up fix