Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在列表中,item高度为wrap_content的时候,icon_with_text会异常,一直重绘高度。 #118

Closed
wangshouz opened this issue Nov 16, 2022 · 6 comments

Comments

@wangshouz
Copy link

页面会一直不停拉升。

@wangshouz
Copy link
Author

image

我感觉是这个计算高度的时候有问题。如果设置了左右icon,还需要判断text的内容高度跟左右icon的高度,不然在左右icon高度大于文字内容高度的时候会导致translateY的计算会有问题,然后导致后续的setPadding会使得mView的高度变高,在调用 invalidate()使得paddingStr.equals(mCacheMultipleIconPaddingVale)一直不成立。

public float getTextHeight(TextView view, int drawableHeight, int paddingTop, int paddingBottom, int drawablePaddingVertical, int iconHeightLeft, int iconHeightRight) {
        if (view == null) return 0;

        /**
         * 1.单行高度*行数
         * 2.最大高度临界值
         */
        Paint.FontMetrics fontMetrics = view.getPaint().getFontMetrics();
        float singleLineHeight = Math.abs((fontMetrics.bottom - fontMetrics.top));//单行高度
        float textHeight = singleLineHeight * view.getLineCount();

        if (textHeight < iconHeightLeft) {
            textHeight = iconHeightLeft;
        }

        if (textHeight < iconHeightRight) {
            textHeight = iconHeightRight;
        }

        //最大高度临界值,不允许超过最大高度临界值
        int maxHeight = view.getHeight() - drawableHeight - paddingTop - paddingBottom - drawablePaddingVertical;//最大允许的宽度
        if (textHeight > maxHeight) {
            textHeight = maxHeight;
        }
        return textHeight;
    }

@UserName-Haha
Copy link

遇到同样的问题

@UserName-Haha
Copy link

必现:只要是小米设备更换字体后且使用了icon就会出现

@RuffianZhong
Copy link
Owner

@wangshouz @UserName-Haha

v0.0.14 版本已经修复此问题,升级版本可以解决

@scsfwgy
Copy link
Contributor

scsfwgy commented Sep 11, 2023

@RuffianZhong 这个仍然有问题,麻烦看一下

@jasonvzhao
Copy link

问题依然存在,小米手机

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants