当前位置: 首页>>代码示例>>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;未经允许,请勿转载。