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