Reset Android textview maxlines

前端 未结 2 858
故里飘歌
故里飘歌 2021-01-31 07:26

I want to make a TextView that is collapsable by user\'s touch. When the TextView collapsed, I set textView.setMaxLines(4);. How to I clear this state in my expand

2条回答
  •  醉话见心
    2021-01-31 07:42

    Try this (infoView.getLineCount()):

    public void onMoreClick(View v) {
        Button btn = (Button) v;
        if(!moreSwitcher) {
            infoView.setMaxLines(infoView.getLineCount());
            infoView.setLines(infoView.getLineCount());
            moreSwitcher = true;
            btn.setText(R.string.collapse);
        }else{
            infoView.setMaxLines(5);
            infoView.setLines(5);
            moreSwitcher = false;
            btn.setText(R.string.expand);
        }
    }
    

提交回复
热议问题