本文整理汇总了Java中android.view.View.getGlobalVisibleRect方法的典型用法代码示例。如果您正苦于以下问题:Java View.getGlobalVisibleRect方法的具体用法?Java View.getGlobalVisibleRect怎么用?Java View.getGlobalVisibleRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.getGlobalVisibleRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVisiblePercent
import android.view.View; //导入方法依赖的package包/类
public int getVisiblePercent(View v) {
Rect scrollBounds = new Rect();
scrollView.getHitRect(scrollBounds);
if (v.getLocalVisibleRect(scrollBounds)) {
// Any portion of the imageView, even a single pixel, is within the visible window
} else {
// NONE of the imageView is within the visible window
return -1;
}
if (v.isShown()) {
Rect r = new Rect();
v.getGlobalVisibleRect(r);
double sVisible = r.width() * r.height();
double sTotal = v.getWidth() * v.getHeight();
MyLg.e(TAG, "sVisible " + sVisible + " sTotal" + sTotal);
return (int) (100 * sVisible / sTotal) - 20;
} else {
return -1;
}
}
示例2: dispatchTouchEvent
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
if ( v instanceof EditText) {
Rect outRect = new Rect();
v.getGlobalVisibleRect(outRect);
if (!outRect.contains((int)event.getRawX(), (int)event.getRawY())) {
v.clearFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
}
return super.dispatchTouchEvent( event );
}
示例3: requestChildFocus
import android.view.View; //导入方法依赖的package包/类
@Override
public void requestChildFocus(View child, View focused) {
/*
* Normally a ScrollView will scroll the child into view.
* Prevent this when a MessageWebView is first touched,
* assuming it already is at least partially in view.
*
*/
if (mSkipWebViewScroll &&
focused instanceof MessageWebView &&
focused.getGlobalVisibleRect(new Rect())) {
mSkipWebViewScroll = false;
super.requestChildFocus(child, child);
ViewParent parent = getParent();
if (parent != null) {
parent.requestChildFocus(this, focused);
}
} else {
super.requestChildFocus(child, focused);
}
}
示例4: checkExposureViewDimension
import android.view.View; //导入方法依赖的package包/类
/**
* check the visible width and height of the view, compared with the its original width and height.
*
* @param view
* @return
*/
private boolean checkExposureViewDimension(View view) {
int width = view.getWidth();
int height = view.getHeight();
Rect GlobalVisibleRect = new Rect();
boolean isVisibleRect = view.getGlobalVisibleRect(GlobalVisibleRect);
if (isVisibleRect) {
int visibleWidth = GlobalVisibleRect.width();
int visibleHeight = GlobalVisibleRect.height();
if ((visibleWidth * 1.00 / width > GlobalsContext.dimThreshold) && (visibleHeight * 1.00 / height > GlobalsContext.dimThreshold)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例5: init
import android.view.View; //导入方法依赖的package包/类
public static int[] init(View view) {
if (view == null) {
return new int[]{ScreenUtil.screenWidth / 2, ScreenUtil.screenHeight / 2, DEFAULT_RADIUS};
}
Rect rect = new Rect();
view.getGlobalVisibleRect(rect);
int height = view.getMeasuredHeight();
int width = view.getMeasuredWidth();
int r = Math.min(width, height);// / 2;
int x = rect.left + width / 2;
int y = rect.top + height / 2;
return new int[]{x, y, r};
}
示例6: onInterceptTouchEvent
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
if (mInterceptTouchListener != null) {
mInterceptTouchListener.onTouch(this, e);
}
//项目特殊处理, 可以删除
for (int i = 0; i < getChildCount(); i++) {
View childAt = getChildAt(0);
Rect rect = new Rect();
childAt.getGlobalVisibleRect(rect);
if (childAt instanceof RecyclerView && rect.contains(((int) e.getRawX()), (int) e.getRawY())) {
//如果touch在另一个RecycleView上面, 那么不拦截事件
return false;
}
}
//--------end--------
return super.onInterceptTouchEvent(e);
}
示例7: dispatchTouchEvent
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
if (v instanceof EditText) {
Rect outRect = new Rect();
v.getGlobalVisibleRect(outRect);
if (!outRect.contains((int) event.getRawX(), (int) event.getRawY())) {
v.clearFocus();
hideKeyBoard();
}
}
}
return super.dispatchTouchEvent(event);
}
示例8: getOutline
import android.view.View; //导入方法依赖的package包/类
@Override
public void getOutline(View view, Outline outline) {
Rect rect = new Rect();
view.getGlobalVisibleRect(rect);
Rect selfRect = RectUtils.getOvalRect(rect);
if(mRect!=null){
selfRect = mRect;
}
outline.setOval(selfRect);
}
示例9: traverseNode
import android.view.View; //导入方法依赖的package包/类
private ArrayList<CopyNode> traverseNode(View nodeInfo, int screenWidth, int scerrnHeight) {
ArrayList nodeList = new ArrayList();
if(nodeInfo != null ) {
if (!nodeInfo.isShown()){
return nodeList;
}
if (nodeInfo instanceof ViewGroup){
ViewGroup viewGroup = (ViewGroup) nodeInfo;
for(int var4 = 0; var4 < viewGroup.getChildCount(); ++var4) {
nodeList.addAll(this.traverseNode(viewGroup.getChildAt(var4), screenWidth, scerrnHeight));
}
}
if(nodeInfo.getClass().getName() != null && nodeInfo.getClass().getName().equals("android.webkit.WebView")) {
return nodeList;
} else {
String content = null;
String description = content;
if(nodeInfo.getContentDescription() != null) {
description = content;
if(!"".equals(nodeInfo.getContentDescription())) {
description = nodeInfo.getContentDescription().toString();
}
}
content = description;
String text=getTextInFilters(nodeInfo,mFilters);
if(text != null) {
content = description;
if(!"".equals(text)) {
content = text.toString();
}
}
if(content != null) {
Rect var8 = new Rect();
nodeInfo.getGlobalVisibleRect(var8);
if(checkBound(var8, screenWidth, scerrnHeight)) {
nodeList.add(new CopyNode(var8, content));
}
}
return nodeList;
}
} else {
return nodeList;
}
}
示例10: getDstRectAfterScale
import android.view.View; //导入方法依赖的package包/类
public Rect getDstRectAfterScale(boolean paramBoolean) {
View localView = getSelectedView();
if (null == localView)
return null;
Rect localRect1 = new Rect();
Rect localRect2 = new Rect();
if ((localView instanceof FocusedRelativeLayout.ScalePostionInterface)) {
FocusedRelativeLayout.ScalePostionInterface localScalePostionInterface = (FocusedRelativeLayout.ScalePostionInterface) localView;
localRect1 = localScalePostionInterface.getScaledRect(getItemScaleXValue(), getItemScaleYValue(), false);
} else {
localView.getGlobalVisibleRect(localRect1);
}
FocusedRelativeLayout.this.getGlobalVisibleRect(localRect2);
localRect1.left -= localRect2.left;
localRect1.right -= localRect2.left;
localRect1.top -= localRect2.top;
localRect1.bottom -= localRect2.top;
localRect1.left += FocusedRelativeLayout.this.mScroller.getCurrX();
localRect1.right += FocusedRelativeLayout.this.mScroller.getCurrX();
if ((paramBoolean) && (isLastFrame())) {
localRect1.top -= getSelectedShadowPaddingTop();
localRect1.left -= getSelectedShadowPaddingLeft();
localRect1.right += getSelectedShadowPaddingRight();
localRect1.bottom += getSelectedShadowPaddingBottom();
} else {
localRect1.top -= getSelectedPaddingTop();
localRect1.left -= getSelectedPaddingLeft();
localRect1.right += getSelectedPaddingRight();
localRect1.bottom += getSelectedPaddingBottom();
}
localRect1.left += getManualPaddingLeft();
localRect1.right += getManualPaddingRight();
localRect1.top += getManualPaddingTop();
localRect1.bottom += getManualPaddingBottom();
return localRect1;
}
示例11: containView
import android.view.View; //导入方法依赖的package包/类
private boolean containView(View paramView) {
Rect localRect1 = new Rect();
Rect localRect2 = new Rect();
getGlobalVisibleRect(localRect1);
paramView.getGlobalVisibleRect(localRect2);
return (localRect1.left <= localRect2.left) && (localRect1.right >= localRect2.right) && (localRect1.top <= localRect2.top) && (localRect1.bottom >= localRect2.bottom);
}
示例12: smoothScrollByOffset
import android.view.View; //导入方法依赖的package包/类
/**
* Allows RemoteViews to scroll relatively to a position.
*/
protected void smoothScrollByOffset(int position) {
int index = -1;
if (position < 0) {
index = getFirstVisiblePosition();
} else if (position > 0) {
index = getLastVisiblePosition();
}
if (index > -1) {
View child = getChildAt(index - getFirstVisiblePosition());
if (child != null) {
Rect visibleRect = new Rect();
if (child.getGlobalVisibleRect(visibleRect)) {
// the child is partially visible
int childRectArea = child.getWidth() * child.getHeight();
int visibleRectArea = visibleRect.width()
* visibleRect.height();
float visibleArea = (visibleRectArea / (float) childRectArea);
final float visibleThreshold = 0.75f;
if ((position < 0) && (visibleArea < visibleThreshold)) {
// the top index is not perceivably visible so offset
// to account for showing that top index as well
++index;
} else if ((position > 0)
&& (visibleArea < visibleThreshold)) {
// the bottom index is not perceivably visible so offset
// to account for showing that bottom index as well
--index;
}
}
smoothScrollToPosition(Math.max(0,
Math.min(getCount(), index + position)));
}
}
}
示例13: getOutline
import android.view.View; //导入方法依赖的package包/类
@Override
public void getOutline(View view, Outline outline) {
Rect rect = new Rect();
view.getGlobalVisibleRect(rect);
int leftMargin = 0;
int topMargin = 0;
Rect selfRect = new Rect(leftMargin, topMargin,
rect.right - rect.left - leftMargin, rect.bottom - rect.top - topMargin);
if(mRect!=null){
selfRect = mRect;
}
outline.setRoundRect(selfRect, mRadius);
}
示例14: explode
import android.view.View; //导入方法依赖的package包/类
/**
* 爆炸
* @param view 爆炸view
* @param isJitterAnima 是否执行抖动动画
* @param listener 动画结束回调
*/
public void explode(final View view, boolean isJitterAnima, OnAnimationEndListener listener) {
Rect r = new Rect();
view.getGlobalVisibleRect(r); //view
int[] location = new int[2];
getLocationOnScreen(location);
r.offset(-location[0], -location[1]);
r.inset(-mExpandInset[0], -mExpandInset[1]);
int startDelay = 100;
if(isJitterAnima){
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration(150);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
Random random = new Random();
@Override
public void onAnimationUpdate(ValueAnimator animation) {
view.setTranslationX((random.nextFloat() - 0.5f) * view.getWidth() * 0.05f);
view.setTranslationY((random.nextFloat() - 0.5f) * view.getHeight() * 0.05f);
}
});
animator.start();
view.animate().setDuration(150).setStartDelay(startDelay).scaleX(0f).scaleY(0f).alpha(0f).start();
}else{
view.setScaleX(0);
view.setScaleY(0);
view.setAlpha(0);
}
explode(BitmapUtils.createBitmapFromView(view), r, startDelay, ExplosionAnimator.DEFAULT_DURATION, listener);
}
示例15: setRect
import android.view.View; //导入方法依赖的package包/类
private void setRect(View view) {
for (UserViewInfo s : mThumbViewInfoList) {
Rect bounds = new Rect();
view.getGlobalVisibleRect(bounds);
s.setBounds(bounds);
}
}