• 计算软键盘的高度然后确定自定义的View的具体位置


            singleTouchView.getViewTreeObserver().addOnGlobalLayoutListener(
                                    new ViewTreeObserver.OnGlobalLayoutListener() {
    
                                            private int heightDifference;
    
                                            <a href="http://home.51cto.com/index.php?s=/space/5017954" target="_blank">@override</a>
                                            public void onGlobalLayout() {
                                                    // TODO Auto-generated method stub
                                                    Rect r = new Rect();
    
                                                    layout.getWindowVisibleDisplayFrame(r);
    
                                                    int screenHeight = layout.getRootView().getHeight();
                                                    //键盘高度
                                                    heightDifference = screenHeight - (r.bottom - r.top);
    
                                    
                                                    if (heightDifference != 0) {
                                                            tl.setLayoutParams(new AbsoluteLayout.LayoutParams(
                                                                            mWidth, mBottomHeight, 0, mHeight
                                                                                            - heightDifference - mBottomHeight));
                                                            tl.setVisibility(View.VISIBLE);
                                                    } else {
                                                            tl.clearAnimation();
                                                            tl.setVisibility(View.INVISIBLE);
                                                    }
                                            }
                                    });

  • 相关阅读:
    jar包和war包的区别:
    tail
    redis
    查看Linux操作系统版本
    CentOS 7.0 systemd代替service
    周刊(三月最后一期)
    周刊第四期
    周刊第三期
    周刊第二期
    周刊(第一期)
  • 原文地址:https://www.cnblogs.com/bimingcong/p/5784834.html
Copyright © 2020-2023  润新知