Set Text View ellipsize and add view more at end

前端 未结 13 1199

I am trying to set ellipsize of text view. using the following code. I want to add \"view more\" at the end of truncated string after 3 dots. If this would be possible with

13条回答
  •  天命终不由人
    2020-12-02 13:25

    This will have ellipsize effect.

    set Boolean isCheck= true;

    put this in the xml:

    
    

    and the code:

    txt_id= (TextView)findViewById(R.id.txt_id);
    txt_id.setText("data");
    txt_id.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View view) {
                       if (isCheck) {
                          txt_id.setMaxLines(10);
                          isCheck = false;
                       } else {
                          txt_id.setMaxLines(2);
                          isCheck = true;
               }
           }
      }
    

提交回复
热议问题