Android Keyboard masking parent layout roll up fix

Source: Internet
Author: User

 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.