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

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

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

Gravity.getAbsoluteGravity介绍

暂无

代码示例

代码示例来源:origin: nickbutcher/plaid

public SlideInItemAnimator(int slideFromEdge, int layoutDirection) {
  this.slideFromEdge = Gravity.getAbsoluteGravity(slideFromEdge, layoutDirection);
  setAddDuration(160L);
}

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

public SlideInItemAnimator(int slideFromEdge, int layoutDirection) {
  this.slideFromEdge = Gravity.getAbsoluteGravity(slideFromEdge, layoutDirection);
  setAddDuration(160L);
}

代码示例来源:origin: ogaclejapan/ArcLayout

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static int getAbsoluteOrigin(int origin, int layoutDirection) {
 return Gravity.getAbsoluteGravity(origin, layoutDirection);
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

absoluteGravity = Gravity.getAbsoluteGravity(realGravity, layoutDirection);

代码示例来源:origin: com.albedinsky.android/ui

/**
   * Compatibility version of {@link Gravity#getAbsoluteGravity(int, int)}.
   */
  @SuppressWarnings("NewApi")
  public static int getAbsoluteGravity(int gravity, int layoutDirection) {
    return RTL_SUPPORT ? Gravity.getAbsoluteGravity(gravity, layoutDirection) : gravity;
  }
}

代码示例来源:origin: com.albedinsky.android/ui-base

/**
   * Compatibility version of {@link Gravity#getAbsoluteGravity(int, int)}.
   */
  @SuppressWarnings("NewApi")
  public static int getAbsoluteGravity(int gravity, int layoutDirection) {
    return RTL_SUPPORT ? Gravity.getAbsoluteGravity(gravity, layoutDirection) : gravity;
  }
}

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

public static int getAbsoluteGravity(int gravity, int layoutDirection) {
  return Gravity.getAbsoluteGravity(gravity, layoutDirection);
}

代码示例来源:origin: xiepeijie/SwipeCardView

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN)
  layoutDirection = getLayoutDirection();
final int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection);
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;

代码示例来源:origin: bboylin/UniversalToast

@TargetApi(JELLY_BEAN_MR1)
@Override
public IToast setGravity(int gravity, int xOffset, int yOffset) {
  final Configuration config = mView.getContext().getResources().getConfiguration();
  final int g = Gravity.getAbsoluteGravity(gravity, config.getLayoutDirection());
  mParams.gravity = g;
  if ((g & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) {
    mParams.horizontalWeight = 1.0f;
  }
  if ((g & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) {
    mParams.verticalWeight = 1.0f;
  }
  mParams.x = xOffset;
  mParams.y = yOffset;
  return this;
}

代码示例来源:origin: rongwu/ToastCompat

/**
 * Set the location at which the notification should appear on the screen.
 *
 * @param gravity
 * @param xOffset
 * @param yOffset
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public IToast setGravity(int gravity, int xOffset, int yOffset) {
  // We can resolve the Gravity here by using the Locale for getting
  // the layout direction
  final int finalGravity;
  if (Build.VERSION.SDK_INT >= 14){
    final Configuration config = mView.getContext().getResources().getConfiguration();
    finalGravity = Gravity.getAbsoluteGravity(gravity, config.getLayoutDirection());
  }else {
    finalGravity = gravity;
  }
  mParams.gravity = finalGravity;
  if ((finalGravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) {
    mParams.horizontalWeight = 1.0f;
  }
  if ((finalGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) {
    mParams.verticalWeight = 1.0f;
  }
  mParams.y = yOffset;
  mParams.x = xOffset;
  return this;
}

代码示例来源:origin: renjianan/GifView

if (Build.VERSION.SDK_INT >= 17){
  final Configuration config = mView.getContext().getResources().getConfiguration();
  finalGravity = Gravity.getAbsoluteGravity(gravity, config.getLayoutDirection());
}else {
  finalGravity = gravity;

代码示例来源:origin: zhitaocai/ToastCompat_Deprecated

/**
 * Set the location at which the notification should appear on the screen.
 *
 * @param gravity
 * @param xOffset
 * @param yOffset
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public IToast setGravity(int gravity, int xOffset, int yOffset) {
  // We can resolve the Gravity here by using the Locale for getting
  // the layout direction
  final int finalGravity;
  if (Build.VERSION.SDK_INT >= 14) {
    final Configuration config = mView.getContext().getResources().getConfiguration();
    finalGravity = Gravity.getAbsoluteGravity(gravity, config.getLayoutDirection());
  } else {
    finalGravity = gravity;
  }
  mParams.gravity = finalGravity;
  if ((finalGravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) {
    mParams.horizontalWeight = 1.0f;
  }
  if ((finalGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) {
    mParams.verticalWeight = 1.0f;
  }
  mParams.y = yOffset;
  mParams.x = xOffset;
  return this;
}

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

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

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

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

代码示例来源:origin: ShonLin/QuickDevFramework

if (Build.VERSION.SDK_INT >= 17) {
  final int layoutDirection = getLayoutDirection();
  absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection);

代码示例来源:origin: wasdennnoch/AndroidN-ify

switch (Gravity.getAbsoluteGravity(Gravity.START, layoutDirection)) {
  case Gravity.RIGHT:

代码示例来源:origin: tylersuehr7/empty-state-recyclerview

/**
 * Sets the overall alignment for the text (supports all gravity variations
 * except for RIGHT and END).
 * @param gravity Text gravity
 */
public void setTextGravity(int gravity) {
  // Let's adjust paint alignment to fit horizontal gravity (END not supported)
  final int horizontalGravity = Gravity.getAbsoluteGravity(gravity,
      ViewCompat.LAYOUT_DIRECTION_LTR)&Gravity.HORIZONTAL_GRAVITY_MASK;
  switch (horizontalGravity) {
    case GravityCompat.START:
      this.titlePaint.setTextAlign(Paint.Align.LEFT);
      this.subtitlePaint.setTextAlign(Paint.Align.LEFT);
      break;
    case Gravity.CENTER_HORIZONTAL:
      this.titlePaint.setTextAlign(Paint.Align.CENTER);
      this.subtitlePaint.setTextAlign(Paint.Align.CENTER);
      break;
  }
  this.textGravity = gravity;
  // No invalidation needed
}

代码示例来源:origin: tylersuehr7/empty-state-recyclerview

final int horizontalGravity = Gravity.getAbsoluteGravity(textGravity,
    ViewCompat.getLayoutDirection(rv))&Gravity.HORIZONTAL_GRAVITY_MASK;

代码示例来源:origin: huxq17/SwipeCardsView

final int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection);
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;

代码示例来源:origin: ViHtarb/Tooltip

private Tooltip(Builder builder) {
  isDismissOnClick = builder.isDismissOnClick;
  mGravity = Gravity.getAbsoluteGravity(builder.mGravity, ViewCompat.getLayoutDirection(builder.mAnchorView));
  mMargin = builder.mMargin;
  mAnchorView = builder.mAnchorView;
  mOnClickListener = builder.mOnClickListener;
  mOnLongClickListener = builder.mOnLongClickListener;
  mOnDismissListener = builder.mOnDismissListener;
  mPopupWindow = new PopupWindow(builder.mContext);
  mPopupWindow.setClippingEnabled(false);
  mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
  mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
  mPopupWindow.setContentView(getContentView(builder));
  mPopupWindow.setBackgroundDrawable(new ColorDrawable());
  mPopupWindow.setOutsideTouchable(builder.isCancelable);
  mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
    @Override
    public void onDismiss() {
      mAnchorView.getViewTreeObserver().removeOnScrollChangedListener(mOnScrollChangedListener);
      mAnchorView.removeOnAttachStateChangeListener(mOnAttachStateChangeListener);
      if (mOnDismissListener != null) {
        mOnDismissListener.onDismiss();
      }
    }
  });
}

相关文章