在Android中,我怎么知道我的edittext字段是否滚动到底部,即最后一行是否完全可见?
我试过这个,但似乎是一个简单的代码太多代码了:
EditText et;
int scrollY = et.getScrollY();
int sum = et.getHeight() + scrollY;
Layout layout = et.getLayout();
int lastVisibleLineNumber = layout.getLineForVertical(sum);
int lineBottom = layout.getLineBottom(lastVisibleLineNumber);
int diff = lineBottom + layout.getBottomPadding() + et.getPaddingBottom() + et.getPaddingTop() - sum;
if (diff <= 0) // Scrolled to the bottom
答案 0 :(得分:0)
你可以使用
android:ellipsize="end"
获得编辑文本的底部。
答案 1 :(得分:0)
你可以尝试
int diff = et.getBottom() - (et.getHeight() + et.getScrollY());