Gravity.apply用于设置红点位置 private void calculateRedPointPosition() { int count = getLineCount(); if (count 0) { rootRect.set(0, 0, getWidth(), getHeight()); int lineIndex = count - 1; getLineBounds(lineIndex, mLineBounds); int y
private void calculateRedPointPosition() {
int count = getLineCount();
if (count > 0) {
rootRect.set(0, 0, getWidth(), getHeight());
int lineIndex = count - 1;
getLineBounds(lineIndex, mLineBounds);
int yAdj = (int) (mLineBounds.top + getPaint().getFontMetrics().ascent - getPaint().getFontMetrics().top);
int xAdj = (int) (rootRect.right - getLayout().getLineRight(lineIndex) - mTipSize - mRightOffset);
Gravity.apply(Gravity.TOP | Gravity.RIGHT, mTipSize, mTipSize, rootRect, xAdj, yAdj, mTipRect);
if (mTipDrawable != null) {
mTipDrawable.setBounds(mTipRect);
}
}
}
