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


Java Gravity.apply方法代碼示例

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


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

示例1: updateBounds

import android.view.Gravity; //導入方法依賴的package包/類
/**
 * 更新bounds
 *
 * @param view
 * @param drawable
 */
private void updateBounds(View view, Drawable drawable) {
    if (drawable != null) {
        final Rect selfBounds = mSelfBounds;
        final Rect overlayBounds = mOverlayBounds;

        final int w = view.getRight() - view.getLeft();
        final int h = view.getBottom() - view.getTop();

        if (mForegroundInPadding) {
            selfBounds.set(0, 0, w, h);
        } else {
            selfBounds.set(view.getPaddingLeft(), view.getPaddingTop(), w - view.getPaddingRight(), h - view.getPaddingBottom());
        }

        Gravity.apply(mForegroundGravity, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), selfBounds, overlayBounds);
        drawable.setBounds(overlayBounds);
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:25,代碼來源:ForegroundDelegate.java

示例2: updateDstRect

import android.view.Gravity; //導入方法依賴的package包/類
private void updateDstRect() {
    if (dirtyDraw) {
        final Rect bounds = getBounds();
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            final int layoutDirection = getLayoutDirection();
            Gravity.apply(Gravity.FILL, bitmap.getWidth(), bitmap.getHeight(),
                    bounds, mDstRect, layoutDirection);
        } else {
            Gravity.apply(Gravity.FILL, bitmap.getWidth(), bitmap.getHeight(),
                    bounds, mDstRect);
        }

    }
    configureRadiusRect();
    dirtyDraw = false;
}
 
開發者ID:leochuan,項目名稱:BubbleView,代碼行數:17,代碼來源:BubbleDrawable.java

示例3: draw

import android.view.Gravity; //導入方法依賴的package包/類
public void draw(@NonNull Canvas canvas) {
    super.draw(canvas);
    if (this.mForeground != null) {
        Drawable foreground = this.mForeground;
        if (this.mForegroundBoundsChanged) {
            this.mForegroundBoundsChanged = false;
            Rect selfBounds = this.mSelfBounds;
            Rect overlayBounds = this.mOverlayBounds;
            int w = getRight() - getLeft();
            int h = getBottom() - getTop();
            if (this.mForegroundInPadding) {
                selfBounds.set(0, 0, w, h);
            } else {
                selfBounds.set(getPaddingLeft(), getPaddingTop(), w - getPaddingRight(), h - getPaddingBottom());
            }
            Gravity.apply(this.mForegroundGravity, foreground.getIntrinsicWidth(), foreground.getIntrinsicHeight(), selfBounds, overlayBounds);
            foreground.setBounds(overlayBounds);
        }
        foreground.draw(canvas);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:ForegroundLinearLayout.java

示例4: onLayout

import android.view.Gravity; //導入方法依賴的package包/類
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    final int layoutWidth = right - left;
    final int layoutHeight = bottom - top;
    if (mIllustration != null) {
        int intrinsicWidth = mIllustration.getIntrinsicWidth();
        int intrinsicHeight = mIllustration.getIntrinsicHeight();

        mViewBounds.set(0, 0, layoutWidth, layoutHeight);
        if (mAspectRatio != 0f) {
            mScale = layoutWidth / (float) intrinsicWidth;
            intrinsicWidth = layoutWidth;
            intrinsicHeight = (int) (intrinsicHeight * mScale);
        }
        Gravity.apply(Gravity.FILL_HORIZONTAL | Gravity.TOP, intrinsicWidth,
                intrinsicHeight, mViewBounds, mIllustrationBounds);
        mIllustration.setBounds(mIllustrationBounds);
    }
    if (mBackground != null) {
        // Scale the background bounds by the same scale to compensate for the scale done to the
        // canvas in onDraw.
        mBackground.setBounds(0, 0, (int) Math.ceil(layoutWidth / mScale),
                (int) Math.ceil((layoutHeight - mIllustrationBounds.height()) / mScale));
    }
    super.onLayout(changed, left, top, right, bottom);
}
 
開發者ID:Trumeet,項目名稱:SetupWizardLibCompat,代碼行數:27,代碼來源:Illustration.java

示例5: draw

import android.view.Gravity; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
  if (isRecycled) {
    return;
  }

  if (applyGravity) {
    Gravity.apply(GifState.GRAVITY, getIntrinsicWidth(), getIntrinsicHeight(), getBounds(),
        getDestRect());
    applyGravity = false;
  }

  Bitmap currentFrame = state.frameLoader.getCurrentFrame();
  canvas.drawBitmap(currentFrame, null, getDestRect(), getPaint());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:GifDrawable.java

示例6: draw

import android.view.Gravity; //導入方法依賴的package包/類
@Override
public void draw(@NonNull Canvas canvas) {
  if (isRecycled) {
    return;
  }

  if (applyGravity) {
    Gravity.apply(GRAVITY, getIntrinsicWidth(), getIntrinsicHeight(), getBounds(), getDestRect());
    applyGravity = false;
  }

  Bitmap currentFrame = state.frameLoader.getCurrentFrame();
  canvas.drawBitmap(currentFrame, null, getDestRect(), getPaint());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:GifDrawable.java

示例7: layoutBadge

import android.view.Gravity; //導入方法依賴的package包/類
private void layoutBadge() {
    Rect badgeBounds = badge.getBounds();
    Gravity.apply(badgeGravity,
            badge.getIntrinsicWidth(),
            badge.getIntrinsicHeight(),
            new Rect(0, 0, getWidth(), getHeight()),
            badgePadding,
            badgePadding,
            badgeBounds);
    badge.setBounds(badgeBounds);
    badgeBoundsSet = true;
}
 
開發者ID:gejiaheng,項目名稱:Protein,代碼行數:13,代碼來源:BadgedFourThreeImageView.java

示例8: apply

import android.view.Gravity; //導入方法依賴的package包/類
public void apply(int gravity, int w, int h, Rect container, Rect outRect, int layoutDirection) {
    Gravity.apply(gravity, w, h, container, outRect);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:4,代碼來源:GravityCompat.java

示例9: draw

import android.view.Gravity; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
    super.draw(canvas);

    if (mForeground != null) {
        final Drawable foreground = mForeground;

        if (mForegroundBoundsChanged) {
            mForegroundBoundsChanged = false;
            final Rect selfBounds = mSelfBounds;
            final Rect overlayBounds = mOverlayBounds;

            final int w = getRight() - getLeft();
            final int h = getBottom() - getTop();

            if (mForegroundInPadding) {
                selfBounds.set(0, 0, w, h);
            } else {
                selfBounds.set(getPaddingLeft(), getPaddingTop(),
                        w - getPaddingRight(), h - getPaddingBottom());
            }

            Gravity.apply(mForegroundGravity, foreground.getIntrinsicWidth(),
                    foreground.getIntrinsicHeight(), selfBounds, overlayBounds);
            foreground.setBounds(overlayBounds);
        }

        foreground.draw(canvas);
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:31,代碼來源:ForegroundLinearLayout.java

示例10: onLayout

import android.view.Gravity; //導入方法依賴的package包/類
/**
 * Position all children within this layout.
 */
@Override
protected void onLayout(boolean changed, int left, int top, int right,
                        int bottom) {
  final int count = getChildCount();

  int leftPos = getPaddingLeft();

  final int parentTop = getPaddingTop();
  final int parentBottom = bottom - top - getPaddingBottom();

  for (int i = 0; i < count; i++) {
    final View child = getChildAt(i);
    if (child.getVisibility() != GONE) {
      final int width = child.getMeasuredWidth();
      final int height = child.getMeasuredHeight();

      mTmpContainerRect.left = leftPos;
      mTmpContainerRect.right = leftPos;
      leftPos = mTmpContainerRect.right;
      mTmpContainerRect.top = parentTop;
      mTmpContainerRect.bottom = parentBottom;

      Gravity.apply(Gravity.TOP | Gravity.LEFT, width, height,
                    mTmpContainerRect, mTmpChildRect);

      child.layout(mTmpChildRect.left, mTmpChildRect.top,
                   mTmpChildRect.right, mTmpChildRect.bottom);
    }
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:34,代碼來源:ScaledFrameLayout.java

示例11: onLayout

import android.view.Gravity; //導入方法依賴的package包/類
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
	final int count = getChildCount();

	// These are the far left and right edges in which we are performing
	// layout.
	int leftPos = getPaddingLeft();
	int rightPos = right - left - getPaddingRight();

	// This is the middle region inside of the gutter.
	final int middleLeft = leftPos + mLeftWidth;
	final int middleRight = rightPos - mRightWidth;

	// These are the top and bottom edges in which we are performing layout.
	final int parentTop = getPaddingTop();
	final int parentBottom = bottom - top - getPaddingBottom();

	for (int i = 0; i < count; i++) {
		final View child = getChildAt(i);
		if (child.getVisibility() != GONE) {
			final LayoutParams lp = (LayoutParams) child.getLayoutParams();

			final int width = child.getMeasuredWidth();
			final int height = child.getMeasuredHeight();

			// Compute the frame in which we are placing this child.
			if (lp.position == LayoutParams.POSITION_LEFT) {
				mTmpContainerRect.left = leftPos + lp.leftMargin;
				mTmpContainerRect.right = leftPos + width + lp.rightMargin;
				leftPos = mTmpContainerRect.right;
			} else if (lp.position == LayoutParams.POSITION_RIGHT) {
				mTmpContainerRect.right = rightPos - lp.rightMargin;
				mTmpContainerRect.left = rightPos - width - lp.leftMargin;
				rightPos = mTmpContainerRect.left;
			} else {
				mTmpContainerRect.left = middleLeft + lp.leftMargin;
				mTmpContainerRect.right = middleRight - lp.rightMargin;
			}
			mTmpContainerRect.top = parentTop + lp.topMargin;
			mTmpContainerRect.bottom = parentBottom - lp.bottomMargin;

			// Use the child's gravity and size to determine its final
			// frame within its container.
			Gravity.apply(lp.gravity, width, height, mTmpContainerRect, mTmpChildRect);

			// Place the child.
			child.layout(mTmpChildRect.left + xPos, mTmpChildRect.top + yPos, mTmpChildRect.right + xPos,
					mTmpChildRect.bottom + yPos);
		}
	}
}
 
開發者ID:KrishAmal,項目名稱:NavAR,代碼行數:52,代碼來源:CustomLayout.java

示例12: apply

import android.view.Gravity; //導入方法依賴的package包/類
public static void apply(int gravity, int w, int h, Rect container, Rect outRect, int layoutDirection) {
    Gravity.apply(gravity, w, h, container, outRect, layoutDirection);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:GravityCompatJellybeanMr1.java

示例13: gravityCompatApply

import android.view.Gravity; //導入方法依賴的package包/類
void gravityCompatApply(int gravity, int bitmapWidth, int bitmapHeight, Rect bounds, Rect outRect) {
    Gravity.apply(gravity, bitmapWidth, bitmapHeight, bounds, outRect, 0);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:RoundedBitmapDrawable21.java


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