当前位置: 首页>>代码示例>>Java>>正文


Java View.getLocalVisibleRect方法代码示例

本文整理汇总了Java中android.view.View.getLocalVisibleRect方法的典型用法代码示例。如果您正苦于以下问题:Java View.getLocalVisibleRect方法的具体用法?Java View.getLocalVisibleRect怎么用?Java View.getLocalVisibleRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.getLocalVisibleRect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
        }
    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:25,代码来源:PlaceDetailActivity.java

示例2: getVisibilityPercents

import android.view.View; //导入方法依赖的package包/类
private int getVisibilityPercents(View view) {
    final Rect currentViewRect = new Rect();

    int percents = 100;

    int height = (view == null || view.getVisibility() != View.VISIBLE) ? 0 : view.getHeight();

    if (height == 0) {
        return 0;
    }

    view.getLocalVisibleRect(currentViewRect);

    if (viewIsPartiallyHiddenTop(currentViewRect)) {
        // view is partially hidden behind the top edge
        percents = (height - currentViewRect.top) * 100 / height;
    } else if (viewIsPartiallyHiddenBottom(currentViewRect, height)) {
        percents = currentViewRect.bottom * 100 / height;
    }

    return percents;
}
 
开发者ID:tohodog,项目名称:QSVideoPlayer,代码行数:23,代码来源:ListCalculator.java

示例3: onTouch

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    switch (motionEvent.getAction()) {
        case MotionEvent.ACTION_DOWN:
            updateBackground(pressedDrawable);
            this.setPadding(mPaddingLeft, mPaddingTop + mShadowHeight, mPaddingRight, mPaddingBottom);
            break;
        case MotionEvent.ACTION_MOVE:
            Rect r = new Rect();
            view.getLocalVisibleRect(r);
            if (!r.contains((int) motionEvent.getX(), (int) motionEvent.getY() + 3 * mShadowHeight) &&
                    !r.contains((int) motionEvent.getX(), (int) motionEvent.getY() - 3 * mShadowHeight)) {
                updateBackground(unpressedDrawable);
                this.setPadding(mPaddingLeft, mPaddingTop + mShadowHeight, mPaddingRight, mPaddingBottom + mShadowHeight);
            }
            break;
        case MotionEvent.ACTION_OUTSIDE:
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            updateBackground(unpressedDrawable);
            this.setPadding(mPaddingLeft, mPaddingTop + mShadowHeight, mPaddingRight, mPaddingBottom + mShadowHeight);
            break;
    }
    return false;
}
 
开发者ID:jaysondc,项目名称:TripleTap,代码行数:26,代码来源:FImageButton.java

示例4: getTheVisibileView

import android.view.View; //导入方法依赖的package包/类
static View getTheVisibileView(List<View> viewList) {
    Rect scrollBounds = new Rect();

    int listSize = viewList.size();
    for (int i = 0; i < listSize; ++i) {
        View view = viewList.get(i);
        if (view != null) {
            view.getHitRect(scrollBounds);
            if (view.getLocalVisibleRect(scrollBounds)) {
                return view;
            }
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Utils.java

示例5: getScreenVisibleRect

import android.view.View; //导入方法依赖的package包/类
/**
 * @return Visible rect in screen coordinates for the given View.
 */
private Rect getScreenVisibleRect(View view) {
    view.getLocalVisibleRect(mScreenVisibleRect);
    view.getLocationOnScreen(mScreenVisiblePoint);
    mScreenVisibleRect.offset(mScreenVisiblePoint[0], mScreenVisiblePoint[1]);
    return mScreenVisibleRect;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:AppMenuDragHelper.java

示例6: checkVisibility

import android.view.View; //导入方法依赖的package包/类
public static int  checkVisibility(View view){

        Rect rect = new Rect();
        boolean b = view.getLocalVisibleRect(rect);
        LogUtil.d("VisibilityCheck", view.getClass().getSimpleName()+": "+ b +"   "+view.getWidth()+view.getHeight()+"  "+rect.toString());
        if(b){
            if(rect.width()==view.getMeasuredWidth() && rect.height()== view.getMeasuredHeight()){//这里用完全可见,也可调节比例
                return ALL_VISIBLE;
            }
            return PART_VISIBLE;

        }
        return ALL_INVISIBLE;
    }
 
开发者ID:YugengWang,项目名称:OneWeather,代码行数:15,代码来源:VisibilityCheckUtil.java

示例7: isVisibleInScreen

import android.view.View; //导入方法依赖的package包/类
/**
 * is the target view visible in local coordinate.
 *
 * @param view the target view
 * @return true if visible.(visible means the view's all side can see).
 */
public static boolean isVisibleInScreen(View view) {
    if (view == null) {
        throw new NullPointerException();
    }
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(dm);
    return view.getLocalVisibleRect(new Rect(0, 0, dm.widthPixels, dm.heightPixels));
}
 
开发者ID:LightSun,项目名称:android-util2,代码行数:16,代码来源:ViewUtil.java

示例8: isViewVisible

import android.view.View; //导入方法依赖的package包/类
public boolean isViewVisible() {
  View view = mAwareChild.getHostView();
  return view != null && view.getLocalVisibleRect(mVisibleRect);

}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:6,代码来源:AppearanceHelper.java


注:本文中的android.view.View.getLocalVisibleRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。