本文整理了Java中android.view.Gravity
类的一些代码示例,展示了Gravity
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gravity
类的具体详情如下:
包路径:android.view.Gravity
类名称:Gravity
暂无
代码示例来源: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: nickbutcher/plaid
public SlideInItemAnimator(int slideFromEdge, int layoutDirection) {
this.slideFromEdge = Gravity.getAbsoluteGravity(slideFromEdge, layoutDirection);
setAddDuration(160L);
}
代码示例来源:origin: wdullaer/MaterialDateTimePicker
public VerticalTextView(Context context, AttributeSet attrs){
super(context, attrs);
final int gravity = getGravity();
if (Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP);
topDown = false;
} else {
topDown = true;
}
}
代码示例来源:origin: ZieIony/Carbon
if (!Gravity.isHorizontal(gravity)) {
if (width < 0) {
gravity |= Gravity.FILL_HORIZONTAL;
if (!Gravity.isVertical(gravity)) {
if (height < 0) {
gravity |= Gravity.FILL_VERTICAL;
代码示例来源:origin: ViHtarb/Tooltip
mContentView.setOrientation(Gravity.isHorizontal(mGravity) ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
if (Gravity.isVertical(mGravity)) {
arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowWidth, (int) builder.mArrowHeight, 0);
} else {
mArrowView.setLayoutParams(arrowLayoutParams);
if (mGravity == Gravity.TOP || mGravity == Gravity.getAbsoluteGravity(Gravity.START, ViewCompat.getLayoutDirection(mAnchorView))) {
mContentView.addView(textView);
mContentView.addView(mArrowView);
代码示例来源:origin: enricocid/LaunchEnr
if (!Gravity.isHorizontal(gravity)) {
setX(x);
if (!Gravity.isVertical(gravity)) {
setY(y);
代码示例来源: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: xinghongfei/LookLook
public SlideInItemAnimator(int slideFromEdge, int layoutDirection) {
this.slideFromEdge = Gravity.getAbsoluteGravity(slideFromEdge, layoutDirection);
setAddDuration(160L);
}
代码示例来源:origin: multidots/android-app-common-tasks
public VerticalTextViewLeft(Context context, AttributeSet attrs) {
super(context, attrs);
final int gravity = getGravity();
if (Gravity.isVertical(gravity)
&& (gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
setGravity((gravity & Gravity.HORIZONTAL_GRAVITY_MASK)
| Gravity.TOP);
topDown = false;
} else {
topDown = true;
}
}
代码示例来源: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: ogaclejapan/ArcLayout
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static int getAbsoluteOrigin(int origin, int layoutDirection) {
return Gravity.getAbsoluteGravity(origin, layoutDirection);
}
代码示例来源:origin: multidots/android-app-common-tasks
public VerticalTextViewRight(Context context, AttributeSet attrs) {
super(context, attrs);
final int gravity = getGravity();
if (Gravity.isVertical(gravity)
&& (gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
setGravity((gravity & Gravity.HORIZONTAL_GRAVITY_MASK)
| Gravity.TOP);
topDown = true;
} else {
topDown = false;
}
}
代码示例来源: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: sjwall/MaterialTapTargetPrompt
absoluteGravity = Gravity.getAbsoluteGravity(realGravity, layoutDirection);
代码示例来源:origin: multidots/android-app-common-tasks
public VerticalTextViewLeft(Context context, AttributeSet attrs) {
super(context, attrs);
final int gravity = getGravity();
if (Gravity.isVertical(gravity)
&& (gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
setGravity((gravity & Gravity.HORIZONTAL_GRAVITY_MASK)
| Gravity.TOP);
topDown = false;
} else {
topDown = true;
}
}
代码示例来源: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: 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: multidots/android-app-common-tasks
public VerticalTextViewRight(Context context, AttributeSet attrs) {
super(context, attrs);
final int gravity = getGravity();
if (Gravity.isVertical(gravity)
&& (gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
setGravity((gravity & Gravity.HORIZONTAL_GRAVITY_MASK)
| Gravity.TOP);
topDown = true;
} else {
topDown = false;
}
}
代码示例来源: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: 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;
}
}
内容来源于网络,如有侵权,请联系作者删除!