一个少妇满足三个老头在线观看,锕锕锕锕锕锕锕好痛视频,亚洲人成网站在线播放2019

<center id="pt2l2"></center>
<tr id="pt2l2"></tr>
  • <big id="pt2l2"></big>

        Android webview input輸入法出來自動壓縮

        在需要填坑的activity的onCreate方法中添加一句AndroidBug5497Workaround.assistActivity(this)即可。

        package com.wetran.ebusiness.ui.view;
        import android.app.Activity;
        import android.graphics.Rect;
        import android.os.Build;
        import android.view.View;
        import android.view.ViewTreeObserver;
        import android.widget.FrameLayout;
        public class AndroidBug5497Workaround {
            public static void assistActivity(Activity activity) {
                new AndroidBug5497Workaround(activity);
            }
            private View mChildOfContent;
            private int usableHeightPrevious;
            private FrameLayout.LayoutParams frameLayoutParams;
            private int contentHeight;
            private boolean isfirst = true;
            private Activity activity;
            private int statusBarHeight;
            private AndroidBug5497Workaround(Activity activity) {
                //獲取狀態欄的高度
                int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
                statusBarHeight = activity.getResources().getDimensionPixelSize(resourceId);
                this.activity = activity;
                FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
                mChildOfContent = content.getChildAt(0);
                //界面出現變動都會調用這個監聽事件
                mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    public void onGlobalLayout() {
                        if (isfirst) {
                            contentHeight = mChildOfContent.getHeight();//兼容華為等機型
                            isfirst = false;
                        }
                        possiblyResizeChildOfContent();
                    }
                });
                frameLayoutParams = (FrameLayout.LayoutParams)
                        mChildOfContent.getLayoutParams();
            }
            //重新調整跟布局的高度
            private void possiblyResizeChildOfContent() {
                int usableHeightNow = computeUsableHeight();
                //當前可見高度和上一次可見高度不一致 布局變動
                if (usableHeightNow != usableHeightPrevious) {
                    //int usableHeightSansKeyboard2 = mChildOfContent.getHeight();//兼容華為等機型
                    int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
                    int heightDifference = usableHeightSansKeyboard - usableHeightNow;
                    if (heightDifference > (usableHeightSansKeyboard / 4)) {
                        // keyboard probably just became visible
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                            //frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
                            frameLayoutParams.height = usableHeightSansKeyboard - heightDifference + statusBarHeight;
                        } else {
                            frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
                        }
                    } else {
                        frameLayoutParams.height = contentHeight;
                    }
                    mChildOfContent.requestLayout();
                    usableHeightPrevious = usableHeightNow;
                }
            }
            /**
            * 計算mChildOfContent可見高度 ** @return
            */
            private int computeUsableHeight() {
                Rect r = new Rect();
                mChildOfContent.getWindowVisibleDisplayFrame(r);
                return (r.bottom - r.top);
            }
        }



        作者:King9527
        鏈接:https://www.jianshu.com/p/d5b93ac1e481
        來源:簡書
        著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。


        若文章對您有幫助,幫忙點個贊!

        0
        0
        發布時間 2021-12-11 18:29:52
        0 條回復(回復會通過微信通知作者)
        點擊加載更多評論
        登錄 后再進行評論
        (微信掃碼即可登錄,無需注冊)
        一个少妇满足三个老头在线观看,锕锕锕锕锕锕锕好痛视频,亚洲人成网站在线播放2019