当前位置 : 主页 > 编程语言 > java >

使用Gravity设置提示红点

来源:互联网 收集:自由互联 发布时间:2021-06-28
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
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 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);
            }
        }
    }
网友评论