获取Textview中一行的字符数

时间:2016-03-05 15:07:56

标签: android android-layout android-edittext textview

我们假设我们有一个大字符串和许多文本视图,它们都有layout_width="match_parent"Textview以及等宽字体。

我需要知道在需要新行之前,我可以在EditText中添加多少字符串。

如果解决方案也适用于"INSERT into Products (productionDate) VALUES (05/03/2016)" ,那就太好了。

1 个答案:

答案 0 :(得分:2)

TextPaint paint = textView.getPaint();
int wordwidth=(int)paint.measureText("a",0,1);
int screenwidth = getResources().getDisplayMetrics().widthPixels;
int num = screenwidth/wordwidth
相关问题