Adnroid Monitoring Soft Keyboard display

Source: Internet
Author: User

First of all, I just want to take a note: http://www.jb51.net/article/64820.htm

At first sight, feel not too reliable, because before all is to see this processing, according to listen to a root layout of size, but that effect is not good, I do not want to use, just want to look for, see this when the test, the effect is great. Also learned the

/**     * Monitor soft keyboard status     *     * @param activity     * @param listener */public    static void Addonsoftkeyboardvisiblelistener (activity activity, final Onsoftkeyboardvisiblelistener listener) {        final View Decorview = Activity.getwindow (). Getdecorview ();        Decorview.getviewtreeobserver (). Addongloballayoutlistener (New Viewtreeobserver.ongloballayoutlistener () {            @ Override public            void Ongloballayout () {                rect rect = new Rect ();                Decorview.getwindowvisibledisplayframe (rect);                int displayhight = rect.bottom-rect.top;                int hight = Decorview.getheight ();                Boolean visible = (double) Displayhight/hight < 0.8;                Listener.onsoftkeyboardvisible (visible);}}        );    }

The interface itself can be defined as follows:

Public interface Onsoftkeyboardvisiblelistener {    void onsoftkeyboardvisible (Boolean visible);

And finally, thank you, big God.

Adnroid Monitoring Soft Keyboard display

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.