當前位置: 首頁>>代碼示例>>Java>>正文


Java View.getWindowVisibleDisplayFrame方法代碼示例

本文整理匯總了Java中android.view.View.getWindowVisibleDisplayFrame方法的典型用法代碼示例。如果您正苦於以下問題:Java View.getWindowVisibleDisplayFrame方法的具體用法?Java View.getWindowVisibleDisplayFrame怎麽用?Java View.getWindowVisibleDisplayFrame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.getWindowVisibleDisplayFrame方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onGlobalLayout

import android.view.View; //導入方法依賴的package包/類
public void onGlobalLayout() {
    int displayHeight;
    View userRootView = this.contentView.getChildAt(0);
    View contentParentView = (View) this.contentView.getParent();
    Rect r = new Rect();
    if (this.isTranslucentStatus) {
        contentParentView.getWindowVisibleDisplayFrame(r);
        displayHeight = (r.bottom - r.top) + this.statusBarHeight;
    } else {
        userRootView.getWindowVisibleDisplayFrame(r);
        displayHeight = r.bottom - r.top;
    }
    calculateKeyboardHeight(displayHeight);
    calculateKeyboardShowing(displayHeight);
    this.previousDisplayHeight = displayHeight;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:KeyboardUtil.java

示例2: takeScreenShot

import android.view.View; //導入方法依賴的package包/類
@SuppressLint({"NewApi"})
public static Bitmap takeScreenShot(Activity pActivity) {
    View view = pActivity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bitmap = view.getDrawingCache();
    Rect frame = new Rect();
    view.getWindowVisibleDisplayFrame(frame);
    int stautsHeight = frame.top;
    Point size = new Point();
    Display display = pActivity.getWindowManager().getDefaultDisplay();
    if (VERSION.SDK_INT < 13) {
        size.set(display.getWidth(), display.getHeight());
    } else {
        pActivity.getWindowManager().getDefaultDisplay().getSize(size);
    }
    return Bitmap.createBitmap(bitmap, 0, stautsHeight, size.x, size.y - stautsHeight);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:19,代碼來源:BitmapUtil.java

示例3: setParams

import android.view.View; //導入方法依賴的package包/類
private void setParams(Context context, WindowManager.LayoutParams lay) {
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(dm);
    Rect rect = new Rect();
    View view = getWindow().getDecorView();
    view.getWindowVisibleDisplayFrame(rect);
    lay.width = dm.widthPixels;
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:10,代碼來源:SobotSelectPicDialog.java

示例4: fadeIn

import android.view.View; //導入方法依賴的package包/類
/**
 * Uses alpha animation to fade in the current view if it's not visible.
 */
void fadeIn() {
    if (getVisibility() == VISIBLE) { return; }

    // Get visible window (keyboard shown)
    Rect r = new Rect();
    final View rootView = getRootView();
    rootView.getWindowVisibleDisplayFrame(r);

    int[] coord = new int[2];
    this.chipsInput.getLocationInWindow(coord);
    ViewGroup.MarginLayoutParams lp = (MarginLayoutParams)getLayoutParams();
    lp.topMargin = coord[1] + chipsInput.getHeight();

    // Height of the keyboard
    lp.bottomMargin = rootView.getHeight() - r.bottom;
    setLayoutParams(lp);

    AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
    anim.setDuration(200);
    startAnimation(anim);

    setVisibility(VISIBLE);
}
 
開發者ID:tylersuehr7,項目名稱:chips-input-layout,代碼行數:27,代碼來源:FilterableRecyclerView.java

示例5: doMonitorSoftKeyWord

import android.view.View; //導入方法依賴的package包/類
/**
 * 判斷軟鍵盤是否彈出
 * * @param rootView
 *
 * @param listener 備注:在不用的時候記得移除OnGlobalLayoutListener
 */
public static ViewTreeObserver.OnGlobalLayoutListener doMonitorSoftKeyWord(final View rootView, final OnSoftKeyWordShowListener listener) {
    final ViewTreeObserver.OnGlobalLayoutListener layoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final Rect rect = new Rect();
            rootView.getWindowVisibleDisplayFrame(rect);
            final int screenHeight = rootView.getRootView().getHeight();
            Log.e("TAG", rect.bottom + "#" + screenHeight);
            final int heightDifference = screenHeight - rect.bottom;
            boolean visible = heightDifference > screenHeight / 3;
            if (listener != null)
                listener.hasShow(visible);
        }
    };
    rootView.getViewTreeObserver().addOnGlobalLayoutListener(layoutListener);
    return layoutListener;
}
 
開發者ID:auv1107,項目名稱:TextEmoji,代碼行數:24,代碼來源:SoftKeyboardUtils.java

示例6: show

import android.view.View; //導入方法依賴的package包/類
/**
 * Show a toast above or below according to the anchor view position.
 *
 * @param anchor The anchor view to show the toast.
 * @param toast The toast to be displayed.
 */
public static void show(@NonNull View anchor, @NonNull Toast toast) {
    final int[] screenPos = new int[2];
    final Rect displayFrame = new Rect();
    anchor.getLocationOnScreen(screenPos);
    anchor.getWindowVisibleDisplayFrame(displayFrame);

    final int viewWidth = anchor.getWidth();
    final int viewHeight = anchor.getHeight();
    final int viewCenterX = screenPos[0] + viewWidth / 2;
    final int screenWidth = anchor.getResources().getDisplayMetrics().widthPixels;
    final int estimatedToastHeight = DynamicUnitUtils
            .convertDpToPixels(ADT_ESTIMATED_TOAST_HEIGHT_DIPS);

    if (screenPos[1] < estimatedToastHeight) {
        toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL,
                viewCenterX - screenWidth / 2,
                screenPos[1] - displayFrame.top - viewHeight);
    } else {
        toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL,
                viewCenterX - screenWidth / 2,
                screenPos[1] - displayFrame.top - estimatedToastHeight);
    }

    toast.show();
}
 
開發者ID:pranavpandey,項目名稱:dynamic-toasts,代碼行數:32,代碼來源:DynamicHint.java

示例7: onGlobalLayout

import android.view.View; //導入方法依賴的package包/類
@Override
public void onGlobalLayout() {
    final View userRootView = contentView.getChildAt(0);
    final View contentParentView = (View) contentView.getParent();

    // Step 1. calculate the current display frame's height.
    Rect r = new Rect();

    final int displayHeight;
    if (isTranslucentStatus) {
        contentParentView.getWindowVisibleDisplayFrame(r);
        displayHeight = (r.bottom - r.top) + statusBarHeight;
    } else {
        userRootView.getWindowVisibleDisplayFrame(r);
        displayHeight = (r.bottom - r.top);
    }

    calculateKeyboardHeight(displayHeight);
    calculateKeyboardShowing(displayHeight);

    previousDisplayHeight = displayHeight;
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:23,代碼來源:KeyboardUtil.java

示例8: isKeyboardShown

import android.view.View; //導入方法依賴的package包/類
/**
 * @param rootView
 * @return
 */
public static boolean isKeyboardShown(View rootView) {
        /* 128dp = 32dp * 4, minimum button height 32dp and generic 4 rows soft keyboard */
    final int softKeyboardHeightThreshold = 128;

    Rect r = new Rect();
    rootView.getWindowVisibleDisplayFrame(r);
    DisplayMetrics dm = rootView.getResources().getDisplayMetrics();
        /* heightDiff = rootView height - status bar height (r.top) - visible frame height (r.bottom - r.top) */
    int heightDiff = rootView.getBottom() - r.bottom;
        /* Threshold size: dp to pixels, multiply with display density */
    return heightDiff > softKeyboardHeightThreshold * dm.density;
}
 
開發者ID:hai-nguyen,項目名稱:Impala,代碼行數:17,代碼來源:Utils.java

示例9: isKeyboardShown

import android.view.View; //導入方法依賴的package包/類
private boolean isKeyboardShown() {
    View mRootContentView = mWindow.getDecorView().findViewById(android.R.id.content);
    if(mRootContentView == null){
        return false;
    }
    final int softKeyboardHeight = 100;
    Rect r = new Rect();
    mRootContentView.getWindowVisibleDisplayFrame(r);
    int heightDiff = mRootContentView.getBottom() - r.bottom;
    DisplayMetrics mDisplayMetrics = getResources().getDisplayMetrics();
    boolean isOpen = heightDiff > softKeyboardHeight * mDisplayMetrics.density;
    return isOpen;
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:14,代碼來源:IMERootLayout.java

示例10: onGlobalLayout

import android.view.View; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
@Override
public void onGlobalLayout() {
    final View userRootView = contentView.getChildAt(0);
    final View actionBarOverlayLayout = (View) contentView.getParent();

    Rect r = new Rect();

    final int displayHeight;
    if (isTranslucentStatus) {
        actionBarOverlayLayout.getWindowVisibleDisplayFrame(r);

        final int overlayLayoutDisplayHeight = (r.bottom - r.top);

        if (!isOverlayLayoutDisplayHContainStatusBar) {
            isOverlayLayoutDisplayHContainStatusBar = overlayLayoutDisplayHeight == screenHeight;
        }

        if (!isOverlayLayoutDisplayHContainStatusBar) {
            displayHeight = overlayLayoutDisplayHeight + statusBarHeight;
        } else {
            displayHeight = overlayLayoutDisplayHeight;
        }

    } else {
        userRootView.getWindowVisibleDisplayFrame(r);
        displayHeight = (r.bottom - r.top);
    }

    calculateKeyboardHeight(displayHeight);
    calculateKeyboardShowing(displayHeight);

    previousDisplayHeight = displayHeight;
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:35,代碼來源:KeyboardManagerImpl.java

示例11: isKeyboardShown

import android.view.View; //導入方法依賴的package包/類
private boolean isKeyboardShown(View rootView) {
    final int softKeyboardHeight = 100;
    Rect frame = new Rect();
    rootView.getWindowVisibleDisplayFrame(frame);
    DisplayMetrics dm = rootView.getResources().getDisplayMetrics();
    int heightDiff = rootView.getBottom() - frame.bottom;
    LogUtils.d("" + rootView.getBottom() + ", " + frame.bottom + ", " + heightDiff);
    return heightDiff > softKeyboardHeight * dm.density;
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:10,代碼來源:KeyboardActivity.java

示例12: getSoftKeyboardHeight

import android.view.View; //導入方法依賴的package包/類
public static int getSoftKeyboardHeight(View view) {
    int screenHeight = view.getResources().getDisplayMetrics().heightPixels;
    Rect rect = new Rect();
    view.getWindowVisibleDisplayFrame(rect);
    int visibleBottom = rect.bottom;
    return screenHeight - visibleBottom;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:8,代碼來源:RSoftInputLayout.java

示例13: isKeyboardShown

import android.view.View; //導入方法依賴的package包/類
private boolean isKeyboardShown(View rootView) {
    final int softKeyboardHeight = 100;
    Rect r = new Rect();
    rootView.getWindowVisibleDisplayFrame(r);
    DisplayMetrics dm = rootView.getResources().getDisplayMetrics();
    int heightDiff = rootView.getBottom() - r.bottom;
    return heightDiff > softKeyboardHeight * dm.density;
}
 
開發者ID:GcsSloop,項目名稱:diycode,代碼行數:9,代碼來源:LoginActivity.java

示例14: isKeyboardVisible

import android.view.View; //導入方法依賴的package包/類
public static boolean isKeyboardVisible(Activity activity) {
    Rect windowFrame = new Rect();
    View root = getActivityRoot(activity);

    if (root != null) {
        root.getWindowVisibleDisplayFrame(windowFrame);
        int heightDiff = root.getRootView().getHeight() - windowFrame.height();
        return heightDiff > WXViewUtils.dip2px(KEYBOARD_VISIBLE_THRESHOLD_DIP);
    }
    return false;
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:12,代碼來源:SoftKeyboardDetector.java

示例15: isKeyboardVisible

import android.view.View; //導入方法依賴的package包/類
/**
 * Determine if keyboard is visible
 *
 * @param activity Activity
 * @return Whether keyboard is visible or not
 */
public static boolean isKeyboardVisible(Activity activity) {
    Rect r = new Rect();

    View activityRoot = QMUIViewHelper.getActivityRoot(activity);
    int visibleThreshold =
            Math.round(QMUIDisplayHelper.dp2px(activity, KEYBOARD_VISIBLE_THRESHOLD_DP));

    activityRoot.getWindowVisibleDisplayFrame(r);

    int heightDiff = activityRoot.getRootView().getHeight() - r.height();

    return heightDiff > visibleThreshold;
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:20,代碼來源:QMUIKeyboardHelper.java


注:本文中的android.view.View.getWindowVisibleDisplayFrame方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。