当前位置: 首页>>代码示例>>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;未经允许,请勿转载。