Limit numbers of lines in TextView

后端 未结 7 1396
忘掉有多难
忘掉有多难 2021-02-01 01:14

I have a scrollable textView, and I want to limit the number of lines displayed, however xml properties are not working :



        
7条回答
  •  独厮守ぢ
    2021-02-01 02:16

    Find your textview by id:

    TextView myTextBox=(TextView)findViewById(R.id.textBox);
    

    Now use the setMaxLines function and assign the number of lines you require in it,say 20.

    myTextBox.setMaxLines(20);
    

    This limits your text box to show 20 lines only.

提交回复
热议问题