简体   繁体   English

如何删除textview的滚动?

[英]How to remove scrolling of textview?

I have a TextView and I am referencing it as "message" in Java and has set it to scrollable like this: 我有一个TextView,我在Java中将它作为“消息”引用,并将其设置为可滚动,如下所示:

 message.setMovementMethod(new ScrollingMovementMethod());

I have another button called "stop" that would take away the scrolling focus from the message textview. 我有另一个名为“停止”的按钮,它会从消息textview中删除滚动焦点。 How can I remove the focus and stop scroll? 如何移除焦点并停止滚动?

From the TextView.setMovementMethod(MovementMethod) -method docs: TextView.setMovementMethod(MovementMethod) -method docs:

Sets the movement method (arrow key handler) to be used for this TextView. 设置要用于此TextView的移动方法(箭头键处理程序)。 This can be null to disallow using the arrow keys to move the cursor or scroll the view. 可以为null以禁止使用箭头键移动光标或滚动视图。

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. 请注意, 如果您希望带有键侦听器或移动方法的TextView不可聚焦 ,或者您希望没有键侦听器或移动方法的TextView可以聚焦,则必须在调用此方法后再次调用setFocusable(boolean)可聚焦性以您想要的方式回归。

So this should remove the focus: 所以这应该消除焦点:

message.setFocusable(false);

while this will take the scrolling away completely: 虽然这将完全滚动:

message.setMovementMethod(null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM