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


Java ViewGroup.getTop方法代码示例

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


在下文中一共展示了ViewGroup.getTop方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateTargetViewLocation

import android.view.ViewGroup; //导入方法依赖的package包/类
private void updateTargetViewLocation() {
    mTargetView.getLocationOnScreen(mTargetLocation);
    int statusBarHeight = getStatusBarHeight(mContext);
    int titleBarHeight = 0;
    if (mContext instanceof Activity) {
        // actionbar height
        Activity activity = (Activity) mContext;
        ViewGroup content = (ViewGroup) activity.findViewById(android.R.id.content);
        titleBarHeight = content.getTop();
        // statusBar height compat
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            WindowManager.LayoutParams params = activity.getWindow().getAttributes();
            boolean isTranslucentStatus = (params.flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) != 0;
            boolean isFitSystemWindows = true;
            if (null != content.getChildAt(0))
                isFitSystemWindows = content.getChildAt(0).getFitsSystemWindows();

            if (isTranslucentStatus && !isFitSystemWindows)
                statusBarHeight = 0;
        }
    }
    mContentTopInWindow = titleBarHeight + statusBarHeight;
    int top = mTargetLocation[1] - mContentTopInWindow;
    mTargetLocation[1] = top;
}
 
开发者ID:devilist,项目名称:SnakeViewMaker,代码行数:26,代码来源:SnakeViewMaker.java

示例2: setIntentByViewGroup

import android.view.ViewGroup; //导入方法依赖的package包/类
private void setIntentByViewGroup(RemoteViews remoteViews, ViewGroup viewGroup, List<RectInfo> list) {
	int count = viewGroup.getChildCount();
	for (int i = 0; i < count; i++) {
		View v = viewGroup.getChildAt(i);
		if (v instanceof ViewGroup) {
			// linearlayout
			setIntentByViewGroup(remoteViews, (ViewGroup) v, list);
		} else if (v instanceof TextView) {
			// textview
			Rect rect = new Rect();
			v.getHitRect(rect);
			// height修正
			rect.top += viewGroup.getTop();
			rect.bottom += viewGroup.getTop();
			PendingIntent pendingIntent = findIntent(rect, list);
			if (pendingIntent != null) {
				remoteViews.setOnClickPendingIntent(v.getId(), pendingIntent);
			}
		}
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:22,代码来源:PendIntentCompat.java

示例3: alignWithIconView

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * Aligns the shadow with {@param view}
 * @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
 */
public void alignWithIconView(BubbleTextView view, ViewGroup viewParent, View clipAgainstView) {
    float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
    float topShift = view.getTop() + viewParent.getTop() - getTop();
    int iconWidth = view.getRight() - view.getLeft();
    int iconHeight = view.getBottom() - view.getTop();
    int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
    float drawableWidth = view.getIcon().getBounds().width();

    if (clipAgainstView != null) {
        // Set the bounds to clip against
        int[] coords = new int[] {0, 0};
        Utilities.getDescendantCoordRelativeToAncestor(clipAgainstView, (View) getParent(),
                coords, false);
        int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
        int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
        setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
    } else {
        // Reset the clip bounds
        setClipBounds(null);
    }

    setTranslationX(leftShift
            + viewParent.getTranslationX()
            + view.getCompoundPaddingLeft() * view.getScaleX()
            + (iconHSpace - drawableWidth) * view.getScaleX() / 2  /* drawable gap */
            + iconWidth * (1 - view.getScaleX()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
    setTranslationY(topShift
            + viewParent.getTranslationY()
            + view.getPaddingTop() * view.getScaleY()  /* drawable gap */
            + view.getHeight() * (1 - view.getScaleY()) / 2  /* gap due to scale */
            - mShadowPadding  /* extra shadow size */
            );
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:40,代码来源:ClickShadowView.java

示例4: drawDivider

import android.view.ViewGroup; //导入方法依赖的package包/类
private void drawDivider(int expPosition, Canvas canvas) {

        final Drawable divider = getDivider();
        final int dividerHeight = getDividerHeight();
        // Log.d("mobeta", "div="+divider+" divH="+dividerHeight);

        if (divider != null && dividerHeight != 0) {
            final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
                    - getFirstVisiblePosition());
            if (expItem != null) {
                final int l = getPaddingLeft();
                final int r = getWidth() - getPaddingRight();
                final int t;
                final int b;

                final int childHeight = expItem.getChildAt(0).getHeight();

                if (expPosition > mSrcPos) {
                    t = expItem.getTop() + childHeight;
                    b = t + dividerHeight;
                } else {
                    b = expItem.getBottom() - childHeight;
                    t = b - dividerHeight;
                }
                // Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);

                // Have to clip to support ColorDrawable on <= Gingerbread
                canvas.save();
                canvas.clipRect(l, t, r, b);
                divider.setBounds(l, t, r, b);
                divider.draw(canvas);
                canvas.restore();
            }
        }
    }
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:36,代码来源:DragSortListView.java

示例5: dispatchDraw

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override protected void dispatchDraw(Canvas canvas) {
  super.dispatchDraw(canvas);
  final ViewGroup row = (ViewGroup) getChildAt(1);
  int top = row.getTop();
  int bottom = getBottom();
  // Left side border.
  final int left = row.getChildAt(0).getLeft() + getLeft();
  canvas.drawLine(left + FLOAT_FUDGE, top, left + FLOAT_FUDGE, bottom, dividerPaint);

  // Each cell's right-side border.
  for (int c = 0; c < 7; c++) {
    float x = left + row.getChildAt(c).getRight() - FLOAT_FUDGE;
    canvas.drawLine(x, top, x, bottom, dividerPaint);
  }
}
 
开发者ID:savvisingh,项目名称:DateRangePicker,代码行数:16,代码来源:CalendarGridView.java

示例6: requestChildFocus

import android.view.ViewGroup; //导入方法依赖的package包/类
/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
    ViewGroup parent = (ViewGroup) mLayout.getParent();
    if (mLayout.getParent() == null) return;

    // Scroll the parent to make the focused child visible.
    if (mFocusedChild != null) parent.requestChildFocus(mLayout, mFocusedChild);

    // {@link View#requestChildFocus} fails to account for children changing their height, so
    // the scroll value may be past the actual maximum.
    int viewportHeight = parent.getBottom() - parent.getTop();
    int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
    if (parent.getScrollY() > scrollMax) parent.setScrollY(scrollMax);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:FocusAnimator.java

示例7: filterViewGroup

import android.view.ViewGroup; //导入方法依赖的package包/类
void filterViewGroup(MotionEvent ev) {
    int downX = Math.round(ev.getX());
    int downY = Math.round(ev.getY());
    int size = mChildViewGroups.size();
    mInAreaViewGroups.clear();
    for (int i = 0; i < size; i++) {
        ViewGroup child = mChildViewGroups.get(i);
        if (child == null || child.getVisibility() == View.GONE)
            continue;
        if (downX > child.getLeft() && downX < child.getRight() && downY > child.getTop() && downY < child.getBottom())
            mInAreaViewGroups.add(child);
    }
}
 
开发者ID:Sunzxyong,项目名称:PullToLoad,代码行数:14,代码来源:PullToRefreshLayout.java

示例8: onInterceptTouchEvent

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
	
	if ((mDragListener != null || mDropListener != null) 
			&& ev.getAction() == MotionEvent.ACTION_DOWN) {
		int x = (int) ev.getX();
		int y = (int) ev.getY();
		int itemnum = pointToPosition(x, y);
		if (itemnum != AdapterView.INVALID_POSITION) {

			ViewGroup item = (ViewGroup) getChildAt(itemnum - getFirstVisiblePosition());
			Log.d("DnD view", "Start dragging at " + (itemnum - getFirstVisiblePosition()) + " for "+ itemnum + " # "+ getFirstVisiblePosition());
			mDragPoint = y - item.getTop();
			mCoordOffset = ((int) ev.getRawY()) - y;
			View dragger = item.findViewById(grabberId);
			if(dragger == null || dragger.getVisibility() == View.GONE) {
			    return super.onInterceptTouchEvent(ev);
			}
			Rect r = mTempRect;
			r.left=dragger.getLeft();
			r.right=dragger.getRight();
			r.top=dragger.getTop();
			r.bottom=dragger.getBottom();   

			if ((r.left<x) && (x<r.right)) {
				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, 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);
				item.setDrawingCacheEnabled(false);
				return false;
			}
			mDragView = null;
		}
	}
	return super.onInterceptTouchEvent(ev);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:47,代码来源:DragnDropListView.java

示例9: Dragger

import android.view.ViewGroup; //导入方法依赖的package包/类
public Dragger(Context context, Setting setting, ViewGroup item, MotionEvent ev) {
	
	mSetting = setting;
          int y = (int) ev.getY();
	
          mDragPointOffset = y - item.getTop();
          mCoordOffset = ((int)ev.getRawY()) - y;
          mRowHeight = item.getHeight();
	
          // enable cache
          // clear cache, otherwise we are going to have problems in donut ;)
          item.setDrawingCacheEnabled(false);
	item.setDrawingCacheEnabled(true);
	// create bitmap
	Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
	mBitmap = bitmap;

	// create window
          mWindowParams = new WindowManager.LayoutParams();
          
          WindowManager.LayoutParams params = mWindowParams;
          params.gravity = Gravity.TOP;
          params.alpha = 0.65f;
          params.x = 0;
          params.y = y - mDragPointOffset + mCoordOffset;

          params.height = WindowManager.LayoutParams.WRAP_CONTENT;
          params.width = WindowManager.LayoutParams.WRAP_CONTENT;
          params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                  | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                  | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                  | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
          params.format = PixelFormat.TRANSLUCENT;
          params.windowAnimations = 0;
          
          ImageView imageView = new ImageView(context);
          int backGroundColor = context.getResources().getColor(android.R.color.black);
          imageView.setBackgroundColor(backGroundColor);
          imageView.setImageBitmap(bitmap);

          // add view
          mWindowManager = (WindowManager) context.getSystemService("window");
          mWindowManager.addView(imageView, params);
          mImageView = imageView;
          
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:47,代码来源:SortableSettingsListView.java

示例10: 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

示例11: animateRevealColor

import android.view.ViewGroup; //导入方法依赖的package包/类
private void animateRevealColor(ViewGroup viewRoot, @ColorRes int color) {
    int cx = (viewRoot.getLeft() + viewRoot.getRight()) / 2;
    int cy = (viewRoot.getTop() + viewRoot.getBottom()) / 2;
    animateRevealColorFromCoordinates(viewRoot, color, cx, cy);
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:6,代码来源:RevealActivity.java


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