當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewGroup.getLocationOnScreen方法代碼示例

本文整理匯總了Java中android.view.ViewGroup.getLocationOnScreen方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewGroup.getLocationOnScreen方法的具體用法?Java ViewGroup.getLocationOnScreen怎麽用?Java ViewGroup.getLocationOnScreen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.getLocationOnScreen方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupFrameLayout

import android.view.ViewGroup; //導入方法依賴的package包/類
private void setupFrameLayout(){
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    ViewGroup contentArea = (ViewGroup) mActivity.getWindow().getDecorView().findViewById(android.R.id.content);
    int [] pos = new int[2];
    contentArea.getLocationOnScreen(pos);
    // frameLayoutWithHole's coordinates are calculated taking full screen height into account
    // but we're adding it to the content area only, so we need to offset it to the same Y value of contentArea

    layoutParams.setMargins(0,-pos[1],0,0);
    contentArea.addView(mFrameLayout, layoutParams);
}
 
開發者ID:AmulaySoftGroup,項目名稱:TaBeTa,代碼行數:12,代碼來源:TourGuide.java

示例2: onInterceptTouchEvent

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (mDragListener != null || mDropListener != null) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                int x = (int) ev.getX();
                int y = (int) ev.getY();
                int itemnum = pointToPosition(x, y);
                if (itemnum == AdapterView.INVALID_POSITION) {
                    break;
                }
                ViewGroup item = (ViewGroup) getChildAt(itemnum - getFirstVisiblePosition());
                mDragPoint = y - item.getTop();
                mCoordOffset = ((int) ev.getRawY()) - y;
                View dragger = item.findViewById(R.id.grabber);
                Rect r = mTempRect;
                dragger.getDrawingRect(r);
                if (shouldStartDragging(x, r.width())) {
                    // Fix x position while dragging
                    int[] itemPos = new int[2];
                    item.getLocationOnScreen(itemPos);

                    item.setDrawingCacheEnabled(true);
                    // Create a copy of the drawing cache so that it does
                    // not get recycled
                    // by the framework when the list tries to clean up
                    // memory
                    Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
                    startDragging(bitmap, itemPos[0], y);
                    mDragPos = itemnum;
                    mFirstDragPos = mDragPos;
                    mHeight = getHeight();
                    int touchSlop = mTouchSlop;
                    mUpperBound = Math.min(y - touchSlop, mHeight / 3);
                    mLowerBound = Math.max(y + touchSlop, mHeight * 2 / 3);
                    return false;
                }
                stopDragging();
                break;
        }
    }
    return super.onInterceptTouchEvent(ev);
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:44,代碼來源:TouchInterceptor.java


注:本文中的android.view.ViewGroup.getLocationOnScreen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。