本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}