zoukankan      html  css  js  c++  java
  • Andoir 判断软键盘是否弹出

    前言
             欢迎大家我分享和推荐好用的代码段~~
    声明
             欢迎转载,但请保留文章原始出处:
             CSDN:
    http://www.csdn.net
             雨季o莫忧离:http://blog.csdn.net/luckkof

    正文

     

     

    	private boolean mHasInit = false;
    	private boolean mHasKeyboard = false;
    	private int mHeight;
        @Override
        protected void onLayout(boolean changed, int l, int t, int r, int b) {
        	// TODO Auto-generated method stub
        	super.onLayout(changed, l, t, r, b);
        	if(!mHasInit) {
    			mHasInit = true;
    			mHeight = b;   
    			System.out.println("mHeight= "+b);
    		} else {
    			mHeight = mHeight < b ? b : mHeight;
    		}
    		
    		if(mHasInit && mHeight > b) {                  //mHeight代表键盘的真实高度 ,b代表在窗口中的高度 mHeight>b 
    			mHasKeyboard = true;
                Xlog.e(TAG, "bottomBar---------------->出来了");
    		}
    		if(mHasInit && mHasKeyboard && mHeight == b) {  // mHeight = b 
    			mHasKeyboard = false;
    			cancelBottomBarAnimation();
                this.setVisibility(View.VISIBLE);
                mShowing = false;
                Xlog.e(TAG, "bottomBar---------------->隐藏了");
    		}
        }


  • 相关阅读:
    学习Python第三天
    学习Python第二天
    学习Python第一天
    centos7 系统优化
    crond计划任务
    day2
    day1
    A.浏览器访问 kube-apiserver 安全端口
    12.清理集群
    11.部署 harbor 私有仓库
  • 原文地址:https://www.cnblogs.com/james1207/p/3343297.html
Copyright © 2011-2022 走看看