gpt4 book ai didi

java - 如何删除textview的滚动?

转载 作者:太空狗 更新时间:2023-10-29 14:18:54 25 4
gpt4 key购买 nike

我有一个 TextView,我在 Java 中将其称为“消息”,并将其设置为可滚动,如下所示:

 message.setMovementMethod(new ScrollingMovementMethod());

我有另一个名为“停止”的按钮,它会从消息 TextView 中移除滚动焦点。如何移除焦点并停止滚动?

最佳答案

来自TextView.setMovementMethod(MovementMethod)-method文档:

Sets the movement method (arrow key handler) to be used for this TextView. This can be null to disallow using the arrow keys to move the cursor or scroll the view.

Be warned that if you want a TextView with a key listener or movement method not to be focusable, or if you want a TextView without a key listener or movement method to be focusable, you must call setFocusable(boolean) again after calling this to get the focusability back the way you want it.

所以这应该移除焦点:

message.setFocusable(false);

虽然这将完全消除滚动:

message.setMovementMethod(null);

关于java - 如何删除textview的滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18812187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com