xamarin android c#Edittext自动滚动到底部

问题描述 投票:0回答:2

我想在Edittext中自动滚动到底部。

我在网上找不到任何关于它的内容。它只关于ListView。

有没有任何解决方案来使用Edittext?

谢谢

c# android xamarin android-edittext
2个回答
0
投票

您可以使用EditText.ScrollTo方法并计算所需的scrollY:

etMain = FindViewById<EditText>(Resource.Id.etMain);
...


//get the lineHeight
int lineHeight = etMain.LineHeight;
//get the line Count
int lineCount = etMain.LineCount+1;
//calculate the scrollY;
int scrollY = lineHeight * lineCount;
//scroll to the bottom
etMain.ScrollTo(0, scrollY);

0
投票

我尝试使用ScrollTo,但它不起作用。

但是使用RequestFocus它有效:)

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.