我可以在 Android 中以编程方式滚动 ScrollView 吗? [英] Can I scroll a ScrollView programmatically in Android?

查看:45
本文介绍了我可以在 Android 中以编程方式滚动 ScrollView 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法以编程方式将 ScrollView 滚动到某个位置?

Is there any way to scroll a ScrollView programmatically to a certain position?

我创建了动态 TableLayout,它被放置在 ScrollView 中.因此,我希望在特定操作(例如单击按钮等)时,特定行应自动滚动到顶部位置.

I have created dynamic TableLayout which is placed in a ScrollView. So I want that on a specific action (like clicking a Button, etc.) the particular row should scroll automatically to a top position.

有可能吗?

推荐答案

ScrollView sv = (ScrollView)findViewById(R.id.scrl);
sv.scrollTo(0, sv.getBottom());

sv.scrollTo(5, 10);

这篇关于我可以在 Android 中以编程方式滚动 ScrollView 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆