本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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());
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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);
}