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