當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。