Skip to content

lineCount in recyclerView example #14

Description

@eggham0518

It's working well.

   `   TextView   tv_content = holder.tv_content;

       tv_content.setText(strContent);

         tv_content.post(new Runnable() {
            @Override
            public void run() {
                int lineCount = tv_content.getLineCount();

                if (lineCount < 4) {
                    return;
                }

                int start = tv_content.getLayout().getLineStart(0);
                int end = tv_content.getLayout().getLineEnd(2);

                int lmitLength;
                
                try {
                    lmitLength = strContent.substring(start, end).length() - 2;
                } catch (Exception e) {
                    return;
                }
                
                if (lmitLength < 0) {
                    return;
                }
                
                CustomReadMoreOption readMoreOption = new CustomReadMoreOption.Builder(mContext)
                        .textLength(lmitLength, ReadMoreOption.TYPE_CHARACTER)
                        .moreLabel("more")
                        .lessLabel("less")
                        .build();

                readMoreOption.addReadMoreTo(tv_content, strContent);

            }
        });``

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions