本文整理汇总了Java中android.view.Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK属性的典型用法代码示例。如果您正苦于以下问题:Java Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK属性的具体用法?Java Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK怎么用?Java Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.Gravity
的用法示例。
在下文中一共展示了Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setForegroundGravity
public void setForegroundGravity(View view, int foregroundGravity) {
if (view != null) {
if (mForegroundGravity != foregroundGravity) {
if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
foregroundGravity |= Gravity.START;
}
if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
foregroundGravity |= Gravity.TOP;
}
mForegroundGravity = foregroundGravity;
if (mForegroundGravity == Gravity.FILL && mForeground != null) {
Rect padding = new Rect();
mForeground.getPadding(padding);
}
view.requestLayout();
}
}
}
示例2: setForegroundGravity
/**
* Describes how the foreground is positioned. Defaults to START and TOP.
*
* @param foregroundGravity See {@link android.view.Gravity}
*
* @see #getForegroundGravity()
*/
public void setForegroundGravity(int foregroundGravity) {
if (mForegroundGravity != foregroundGravity) {
if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
foregroundGravity |= Gravity.START;
}
if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
foregroundGravity |= Gravity.TOP;
}
mForegroundGravity = foregroundGravity;
if (mForegroundGravity == Gravity.FILL && mForeground != null) {
Rect padding = new Rect();
mForeground.getPadding(padding);
}
requestLayout();
}
}
示例3: setGravity
/**
* Sets the horizontal alignment of the text and the
* vertical gravity that will be used when there is extra space
* in the TextView beyond what is required for the text itself.
*
* @see android.view.Gravity
*/
public boolean setGravity(int gravity) {
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.START;
}
if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.TOP;
}
boolean newLayout = false;
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) !=
(mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK)) {
newLayout = true;
}
if (gravity != mGravity) {
newLayout = true;
}
mGravity = gravity;
return newLayout;
}
示例4: getAlignmentByGravity
private static Layout.Alignment getAlignmentByGravity(int gravity) {
switch (gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
case Gravity.START:
return Layout.Alignment.ALIGN_NORMAL;
case Gravity.END:
return Layout.Alignment.ALIGN_OPPOSITE;
case Gravity.LEFT:
return Layout.Alignment.ALIGN_LEFT;
case Gravity.RIGHT:
return Layout.Alignment.ALIGN_RIGHT;
case Gravity.CENTER_HORIZONTAL:
return Layout.Alignment.ALIGN_CENTER;
default:
return Layout.Alignment.ALIGN_NORMAL;
}
}
示例5: ReactEditText
public ReactEditText(Context context) {
super(context);
setFocusableInTouchMode(false);
mInputMethodManager = (InputMethodManager)
Assertions.assertNotNull(getContext().getSystemService(Context.INPUT_METHOD_SERVICE));
mDefaultGravityHorizontal =
getGravity() & (Gravity.HORIZONTAL_GRAVITY_MASK | Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK);
mDefaultGravityVertical = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
mNativeEventCount = 0;
mMostRecentEventCount = 0;
mIsSettingTextFromJS = false;
mIsJSSettingFocus = false;
mBlurOnSubmit = true;
mDisableFullscreen = false;
mListeners = null;
mTextWatcherDelegator = null;
mStagedInputType = getInputType();
mKeyListener = new InternalKeyListener();
mScrollWatcher = null;
}
示例6: setGravity
/**
* Describes how the child views are positioned. Defaults to GRAVITY_TOP. If
* this layout has a VERTICAL orientation, this controls where all the child
* views are placed if there is extra vertical space. If this layout has a
* HORIZONTAL orientation, this controls the alignment of the children.
*
* @param gravity
* See {@link Gravity}
*/
private void setGravity(int gravity) {
if (mGravity != gravity) {
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
gravity |= GravityCompat.START;
}
if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.TOP;
}
mGravity = gravity;
requestLayout();
}
}
示例7: setHorizontalGravity
public void setHorizontalGravity(int horizontalGravity) {
final int gravity = horizontalGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK;
if ((mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) != gravity) {
mGravity = (mGravity & ~GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) | gravity;
requestLayout();
}
}
示例8: setIndicatorGravity
public BannerView setIndicatorGravity(int gravity) {
if (mGravity != gravity) {
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.START;
}
if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.TOP;
}
mGravity = gravity;
}
return this;
}
示例9: onDraw
@Override
protected void onDraw(Canvas canvas) {
long start = System.currentTimeMillis();
canvas.save();
if (mLayout != null) {
int translateX, translateY;
int horizontalGravity = getGravity() & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK;
switch (horizontalGravity) {
default:
case Gravity.LEFT:
translateX = getPaddingLeft();
break;
case Gravity.CENTER_HORIZONTAL:
translateX = getPaddingLeft() + (getInnerWidth() - mLayout.getWidth()) / 2;
break;
case Gravity.RIGHT:
translateX = getPaddingLeft() + getInnerWidth() - mLayout.getWidth();
break;
}
int verticalGravity = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
switch (verticalGravity) {
default:
case Gravity.TOP:
translateY = getPaddingTop();
break;
case Gravity.CENTER_VERTICAL:
translateY = getPaddingTop() + (getInnerHeight() - mLayout.getHeight()) / 2;
break;
case Gravity.BOTTOM:
translateY = getPaddingTop() + getInnerHeight() - mLayout.getHeight();
break;
}
canvas.translate(translateX, translateY);
mLayout.draw(canvas);
}
canvas.restore();
long end = System.currentTimeMillis();
if (BuildConfig.DEBUG) {
Log.d(TAG, "onDraw cost:" + (end - start));
}
}
示例10: ReactTextView
public ReactTextView(Context context) {
super(context);
mDefaultGravityHorizontal =
getGravity() & (Gravity.HORIZONTAL_GRAVITY_MASK | Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK);
mDefaultGravityVertical = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
}