视频介绍,同一行显示更多效果展示

先看效果如下:
点击查看更多
简单代码示例:
tvMark 介绍
tvMore 更多 按钮

tvMark.setText(TextUtils.isEmpty(video.getContent()) ? "暂无介绍" : video.getContent());
        tvMark.post(new Runnable() {
            @Override
            public void run() {
                Layout layout = tvMark.getLayout();
                if (layout != null) {
                    int lines = layout.getLineCount();
                    if (lines > 0) {
                        int ellipsisCount = layout.getEllipsisCount(lines - 1);
                        if (ellipsisCount > 0) {
                            CharSequence markText = tvMark.getText();
                            CharSequence charSequence = markText.subSequence(0, markText.length() - ellipsisCount-2);
                            tvMark.setText(charSequence + "...   ");
                            tvMore.setVisibility(View.VISIBLE);
                        } else {
                            tvMore.setVisibility(View.GONE);
                        }
                    }
                }
            }
        });
发布了28 篇原创文章 · 获赞 17 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/wfs31415926/article/details/88792613