2

指定されたテキストで textView がいっぱいかどうかを動的に確認したい。つまり、TextView では、Text を動的に割り当てます。また、その TextView が指定されたテキストでいっぱいかどうかを確認したいと思います。そのテキストビューはカスタムリストビューにあります。私のテキストビューには最大行3があります。

4

3 に答える 3

4

you need to calculate the size of your textview and the size of your text. Try this to find size of your text view

int text_view_size = text_view.getLayoutParams().width;

and this for finding the size of your text

 int text_size = getTextSize(text_view.getText().toString());

this is getTextSize method

private int getTextSize(String your_text){
    Paint p = new Paint();
    //Calculate the text size in pixel
    return p.measureText(your_text);
}

Now you can check using text watTextWatcher class that your text exceeds the size of your text view.

于 2013-10-30T06:56:54.787 に答える
-1

これを試して

if(textView.getText().toString().trim().length()<=0)
{
      //here your textview has no text
} 
于 2013-10-30T06:46:02.837 に答える