Android edit box is masked by input method, effective processing method

Source: Internet
Author: User

This problem occurs mainly after 4.4, allowing the use of the immersive title bar after 4.4 or 4.4 without using the immersive title bar is no problem, so if your app uses an immersive title bar, and you need to enter content, you can use this method

1. Add a layer of scrollview to the outside of the main part of the XML, which is where the red circle in the graph

2. Add this code to the activity's OnCreate

  If  (build.version.   Sdk_int      >= { final  View Decorview = GetWindow (). Getdecorview (); Decorview.getviewtreeobserver (). Addongloballayoutlistener ( New             Viewtreeobserver.ongloballayoutlistener () {@Override  public void  ongloballayout () {            Rect rect =  new  rect ();            Decorview.getwindowvisibledisplayframe (rect);             int  screenheight = Decorview.getrootview (). GetHeight ();             int  height = screenheight-rect.  bottom ; Layoutparams layoutparams =  ScrollView . Getlayoutparams ();//(            What type of layoutparams is dependent on what type of ScrollView parent is layoutparams.setmargins (0,0,0,height);         ScrollView . Requestlayout (); }    });}

Usually this is OK, but there is a small problem, like I have a button in the page below, the button is not in ScrollView, this situation will cause the actual display of the input method at the top and the current input edit box between the interval, the distance is the distance of the button, which The distance should be to put this button, but I do not know how to let this button up in the input, like before 4.4

This is the top of the XML layout include the title, TextView is the Submit button, the following is the middle of the body ScrollView

I put this more stupid method to write, because I was in the solution of this problem Baidu Google for a long time there is no real good plan, I this program although not very good, but at least to solve the problem, I hope to help you, if there is a better solution, please enlighten me

qq:1075770442

Android edit box is masked by input method, effective processing method

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.