how to use getlinecount() in textview android

前端 未结 6 1735
忘掉有多难
忘掉有多难 2021-01-12 02:03

i want to know how many line in my text view. i already set mytextview text, then i want to get how many line it take in mytextview.

i use mytextview.getLineCount()

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-12 02:53

    you can check the TextView parameters inside onCreateOptionsMenu()

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        TextView tv1 = (TextView)findViewById(R.id.textView);
        Rect rect = new Rect();
        int c = tv1.getLineCount();
        tv1.getLineBounds(0, rect);
        tv1.getLineBounds(1, rect);
        return true;
    }
    

提交回复
热议问题