When TextView displays no more than three rows of data, the following expand button is not displayed. In this case, you must obtain the number of lines in TextView. You can view the getLineCount () method: when I use it happily, I can rest assured that the returned value is always blank. Then I checked Google and found that it was necessary to completely draw the TextView before obtaining the number of rows, the solution is to enable asynchronous retrieval. The following is a specific method:
Private class MyOpenTask extends AsyncTask <Integer, Integer, Integer> {private int [] location = new int [2]; @ Override protected void onCancelled () {super. onCancelled () ;}public void start () {execute (0) ;}@ Override protected Integer doInBackground (Integer... params) {return 1 ;}@ Override protected void onPostExecute (Integer result) {super. onPostExecute (result); int linecount = mVideoDescription. getLineCount (); android. util. log. e ("MvDetail", "linecount1:" + linecount); if (linecount> 3) {openTV. setVisibility (View. VISIBLE); openIV. setVisibility (View. VISIBLE); openTV. setText ("show all"); mVideoDescription. setClickable (true); openFlag = false;} else {openTV. setVisibility (View. GONE); openIV. setVisibility (View. GONE); mVideoDescription. setClickable (false );}}}