首页 > 系统 > Android > 正文

Android检测输入法弹出与隐藏

2019-11-07 23:37:26
字体:
来源:转载
供稿:网友

代码很简单,我就直接贴出来了.

        mActivityMain = (LinearLayout) findViewById(R.id.activity_main); //根布局        mActivityMain.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {            @Override            public void onGlobalLayout() {                int height = mActivityMain.getRootView().getHeight() - mActivityMain.getHeight();                if (height>100) {                    System.out.PRintln("输入法弹出了");                }else{                    System.out.println("输入法关闭了");                }            }        });根布局如下:

<LinearLayout    xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/activity_main"    android:orientation="vertical"    android:layout_width="match_parent"    android:layout_height="match_parent">


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表