當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。