当前位置: 首页>>代码示例>>Java>>正文


Java Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK属性代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:22,代码来源:ForegroundDelegate.java

示例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();
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:28,代码来源:ForegroundLinearLayout.java

示例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;
}
 
开发者ID:lsjwzh,项目名称:FastTextView,代码行数:29,代码来源:TextViewAttrsHelper.java

示例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;
  }
}
 
开发者ID:lsjwzh,项目名称:FastTextView,代码行数:16,代码来源:TextViewAttrsHelper.java

示例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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:21,代码来源:ReactEditText.java

示例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();
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:23,代码来源:AutoLinearLayout.java

示例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();
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:7,代码来源:AutoLinearLayout.java

示例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;
}
 
开发者ID:lany192,项目名称:BannerView,代码行数:12,代码来源:BannerView.java

示例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));
  }
}
 
开发者ID:lsjwzh,项目名称:FastTextView,代码行数:41,代码来源:FastTextView.java

示例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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:6,代码来源:ReactTextView.java


注:本文中的android.view.Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。