ScrollView滚动到底部使用的scrollTo和fullScroll方法的异同

本文探讨了在Android中,如何使用ScrollView的scrollTo和fullScroll方法来实现滚动到底部的功能。虽然两者都能达到滚动目的,但fullScroll涉及到焦点变化,当参数设为FOCUS_DOWN时,会改变视图焦点。而scrollTo只是简单地移动到指定位置,不改变其他属性。因此,使用fullScroll需要注意焦点的改变,当底部元素无法获取焦点时,该方法可能无效。
摘要由CSDN通过智能技术生成

scrollTo和fullScroll两个方法经常被用来做滚动到底部的操作

不过就这个功能而言 也是有不同之处的

使用fullScroll滚动到底部 使用的参数为 FOCUS_DOWN 顾名思义 和 焦点有关

fullScroll 代码如下

/**
 * <p>Handles scrolling in response to a "home/end" shortcut press. This
 * method will scroll the view to the top or bottom and give the focus
 * to the topmost/bottommost component in the new visible area. If no
 * component is a good candidate for focus, this scrollview reclaims the
 * focus.</p>
 *
 * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
 *                  to go the top of the view or
 *                  {@link android.view.View#FOCUS_DOWN} to go the bottom
 * @return true if the key event is consumed by this method, false otherwise
 */
public
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值