根据屏幕尺寸设置EditText高度和最大行数的限制 [英] Set limitation for EditText height and maximum lines according to the screen size

查看:351
本文介绍了根据屏幕尺寸设置EditText高度和最大行数的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个笔记本应用程序,我想根据屏幕高度限制editText的最大行数.例如nexus-6p中的40行和nexus5中的35行等等.

I have a notebook application and I want to limit my editText maximum lines according to the screen height. for example 40 lines in nexus-6p and 35 lines in nexus5 and etc.

所以我的问题是如何限制editText行? 我对此一无所知.

So my question is how can I limit the editText lines? I don't have any idea for this.

更新

我要在光标到达最后一行时创建新的笔记页面.

I want to create new note page when cursor reached the last line.

推荐答案

我找到了解决方案,感谢大家的答复.

I Found the solution, thank everyone for the response.

我的解决方法是:

int lineHeight = getLineHeight();
int height = getHeight();
int maximumLines = height / lineHeight();

这篇关于根据屏幕尺寸设置EditText高度和最大行数的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆