android.view.Gravity.apply()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中android.view.Gravity.apply()方法的一些代码示例,展示了Gravity.apply()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gravity.apply()方法的具体详情如下:
包路径:android.view.Gravity
类名称:Gravity
方法名:apply

Gravity.apply介绍

暂无

代码示例

代码示例来源:origin: xinghongfei/LookLook

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;
}

代码示例来源:origin: bumptech/glide

@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());
}

代码示例来源:origin: alexvasilkov/GestureViews

/**
 * Calculates image position (scaled and rotated) within viewport area with gravity applied.
 *
 * @param matrix Image matrix
 * @param settings Image settings
 * @param out Output rectangle
 */
public static void getImagePosition(Matrix matrix, Settings settings, Rect out) {
  tmpRectF.set(0, 0, settings.getImageW(), settings.getImageH());
  matrix.mapRect(tmpRectF);
  final int w = Math.round(tmpRectF.width());
  final int h = Math.round(tmpRectF.height());
  // Calculating image position basing on gravity
  tmpRect1.set(0, 0, settings.getViewportW(), settings.getViewportH());
  Gravity.apply(settings.getGravity(), w, h, tmpRect1, out);
}

代码示例来源:origin: alexvasilkov/GestureViews

private void getIconMatrix(Marker marker, Matrix out) {
  // Positioning focal point within marker icon according to provided gravity.
  // In the end we should have a matrix which is when applied to the icon will position
  // it's focal point (specified by gravity + offsets) at (0, 0)
  final Drawable icon = marker.getIcon();
  iconRect.set(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
  Gravity.apply(marker.getGravity(), 0, 0, iconRect, posRect);
  out.reset();
  out.postTranslate(-posRect.left, -posRect.top);
  out.postTranslate(marker.getOffsetX(), marker.getOffsetY());
  final float scale = marker.getScale();
  if (scale != 1f) {
    out.postScale(scale, scale);
  }
  final float rotation = marker.getRotation();
  if (rotation != 0f) {
    out.postRotate(rotation);
  }
}

代码示例来源:origin: alexvasilkov/GestureViews

/**
 * Calculates default pivot point for scale and rotation.
 *
 * @param settings Image settings
 * @param out Output point
 */
public static void getDefaultPivot(Settings settings, Point out) {
  getMovementAreaPosition(settings, tmpRect2);
  Gravity.apply(settings.getGravity(), 0, 0, tmpRect2, tmpRect1);
  out.set(tmpRect1.left, tmpRect1.top);
}

代码示例来源:origin: alexvasilkov/GestureViews

/**
 * Calculates movement area position within viewport area with gravity applied.
 *
 * @param settings Image settings
 * @param out Output rectangle
 */
public static void getMovementAreaPosition(Settings settings, Rect out) {
  tmpRect1.set(0, 0, settings.getViewportW(), settings.getViewportH());
  Gravity.apply(settings.getGravity(),
      settings.getMovementAreaW(), settings.getMovementAreaH(), tmpRect1, out);
}

代码示例来源:origin: guolindev/giffun

@Override
public void draw(Canvas canvas) {
  if (applyGravity) {
    Gravity.apply(BitmapState.GRAVITY, width, height, getBounds(), destRect);
    applyGravity = false;
  }
  canvas.drawBitmap(state.bitmap, null, destRect, state.paint);
}

代码示例来源:origin: guolindev/giffun

@Override
public void draw(Canvas canvas) {
  if (isRecycled) {
    return;
  }
  if (applyGravity) {
    Gravity.apply(GifState.GRAVITY, getIntrinsicWidth(), getIntrinsicHeight(), getBounds(), destRect);
    applyGravity = false;
  }
  Bitmap currentFrame = frameLoader.getCurrentFrame();
  Bitmap toDraw = currentFrame != null ? currentFrame : state.firstFrame;
  canvas.drawBitmap(toDraw, null, destRect, paint);
}

代码示例来源:origin: AlexMofer/ProjectX

static void apply(int gravity, int w, int h, Rect container,
             Rect outRect, int layoutDirection) {
  if (SDK_INT >= 17) {
    Gravity.apply(gravity, w, h, container, outRect, layoutDirection);
  } else {
    Gravity.apply(gravity, w, h, container, outRect);
  }
}

代码示例来源:origin: kingargyle/adt-leanback-support

@Override
  void gravityCompatApply(int gravity, int bitmapWidth, int bitmapHeight,
      Rect bounds, Rect outRect) {
    Gravity.apply(gravity, bitmapWidth, bitmapHeight,
        bounds, outRect, View.LAYOUT_DIRECTION_LTR);
  }
}

代码示例来源:origin: kingargyle/adt-leanback-support

@Override
public void apply(int gravity, int w, int h, Rect container, int xAdj, int yAdj,
    Rect outRect, int layoutDirection) {
  Gravity.apply(gravity, w, h, container, xAdj, yAdj, outRect);
}

代码示例来源:origin: kingargyle/adt-leanback-support

@Override
public void apply(int gravity, int w, int h, Rect container, Rect outRect,
    int layoutDirection) {
  Gravity.apply(gravity, w, h, container, outRect);
}

代码示例来源:origin: kingargyle/adt-leanback-support

public static void apply(int gravity, int w, int h, Rect container, int xAdj, int yAdj,
    Rect outRect, int layoutDirection) {
  Gravity.apply(gravity, w, h, container, xAdj, yAdj, outRect, layoutDirection);
}

代码示例来源:origin: kingargyle/adt-leanback-support

public static void apply(int gravity, int w, int h, Rect container, Rect outRect,
    int layoutDirection) {
  Gravity.apply(gravity, w, h, container, outRect, layoutDirection);
}

代码示例来源:origin: AlexMofer/ProjectX

static void apply(Drawable drawable, int gravity, int w, int h, Rect container, Rect outRect) {
  if (drawable == null)
    return;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
    Gravity.apply(gravity, w, h, container, outRect, drawable.getLayoutDirection());
  else
    Gravity.apply(gravity, w, h, container, outRect);
}

代码示例来源:origin: githubwing/RichTextView

/** Align drawable in wrapper in case the image is smaller than the target size. */
  private Rect calcBounds(Drawable drawable, int gravity) {
    Rect bounds = new Rect();
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    Rect container = wrapper.getBounds();
    if (w == -1 && h == -1) {
      w = container.width();
      h = container.height();
    }
    Gravity.apply(gravity, w, h, container, bounds);
    return bounds;
  }
}

代码示例来源:origin: JackWHLiu/jackknife

public static Bitmap composeWatermark(Bitmap dstBitmap, Bitmap markBitmap, int gravity, float offsetX, float offsetY) {
  if (dstBitmap == null) {
    return null;
  }
  Bitmap outputBitmap = Bitmap.createBitmap(dstBitmap.getWidth(), dstBitmap.getHeight(),
      Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(outputBitmap);
  canvas.drawBitmap(dstBitmap, 0, 0, null);
  Rect outRect = new Rect();
  Rect containerRect = new Rect(0, 0, dstBitmap.getWidth(), dstBitmap.getHeight());
  Gravity.apply(gravity, outputBitmap.getWidth(), outputBitmap.getHeight(), containerRect, outRect);
  int left = (int) (outRect.left+offsetX);
  int top = (int) (outRect.top+offsetY);
  int right = (int) (outRect.right+offsetX);
  int bottom = (int) (outRect.bottom+offsetY);
  outRect.set(left, top, right, bottom);
  canvas.drawBitmap(markBitmap, null, outRect, null);
  canvas.save(Canvas.ALL_SAVE_FLAG);
  canvas.restore();
  return outputBitmap;
}

代码示例来源:origin: yesidlazaro/BadgedImageview

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;
  }
}

代码示例来源:origin: ImangazalievM/Bubbble

private void layoutBadge() {
    Rect badgeBounds = badge.getBounds();
    Gravity.apply(badgeGravity,
        badge.getIntrinsicWidth(),
        badge.getIntrinsicHeight(),
        new Rect(0, 0, getWidth(), getHeight()),
        badgePaddingX != 0 ? badgePaddingX : badgePadding,
        badgePaddingY != 0 ? badgePaddingY : badgePadding,
        badgeBounds);
    badge.setBounds(badgeBounds);
    badgeBoundsSet = true;
  }
}

代码示例来源:origin: klinker24/Android-BadgedImageView

private void layoutBadge() {
    Rect badgeBounds = badge.getBounds();
    Gravity.apply(badgeGravity,
        badge.getIntrinsicWidth(),
        badge.getIntrinsicHeight(),
        new Rect(0, 0, getWidth(), getHeight()),
        badgePaddingX != 0 ? badgePaddingX : badgePadding,
        badgePaddingY != 0 ? badgePaddingY : badgePadding,
        badgeBounds);
    badge.setBounds(badgeBounds);
    badgeBoundsSet = true;
  }
}

相关文章