有没有一种方法以编程方式滚动滚动视图到一个特定的编辑文本? [英] Is there a way to programmatically scroll a scroll view to a specific edit text?

查看:115
本文介绍了有没有一种方法以编程方式滚动滚动视图到一个特定的编辑文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滚动视图很长的活动。它与各个领域的一种形式,用户必须填写。我有一个复选框一半时我的形式,当用户检查它,我要滚动到视图的特定部分。有没有什么办法可以滚动到一个EditText对象(或任何其他视图对象)编程?

另外,我知道这是可能使用X和Y COORDS,但我想避免这样的形式可以改变从用户到用户。

解决方案

 私人最终无效focusOnView(){
        新的处理程序()。后(新的Runnable(){
            @覆盖
            公共无效的run(){
                your_scrollview.scrollTo(0,your_EditBox.getBottom());
            }
        });
    }
 

I have a very long activity with a scrollview. It is a form with various fields that the user must fill in. I have a checkbox half way down my form, and when the user checks it I want to scroll to a specific part of the view. Is there any way to scroll to an EditText object (or any other view object) programmatically?

Also, I know this is possible using X and Y coords but I want to avoid doing this as the form may changed from user to user.

解决方案

private final void focusOnView(){
        new Handler().post(new Runnable() {
            @Override
            public void run() {
                your_scrollview.scrollTo(0, your_EditBox.getBottom());
            }
        });
    }

这篇关于有没有一种方法以编程方式滚动滚动视图到一个特定的编辑文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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