滚动型卧式全向右滚动注重与ViewTreeObserver [英] Horizontal ScrollView full Scroll focus right with ViewTreeObserver

查看:190
本文介绍了滚动型卧式全向右滚动注重与ViewTreeObserver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加入的对象到水平滚动视图动态,当我加入code以下工作正常移动极右,现在的问题是,当我尝试通过交换手指$ C $滚动回左边下面C再次运行和水平滚动视图滚动到右侧角球再次,它有点恼人的,任何人都具有一定的替代解决方案,我已经尽力了。

I am adding the objects into the horizontal scrollview dynamically and when i add the code below works fine to move extreme right, now the problem is when i try to scroll back to left side via swapping finger the code below again runs and horizontal scrollview scrolls to the right corner again, its a bit annoying, anyone has some alternate solution, I ve tried the

Postdelayed()

Postdelayed()

但它不为我正常工作

ViewTreeObserver viewTreeObserver = hScrollView.getViewTreeObserver();
        if (viewTreeObserver.isAlive()) {
            viewTreeObserver
                    .addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
                        @Override
                        public void onGlobalLayout() {
                            // interestedInView is ready for size and position
                            // queries because it has been laid out
                            hScrollView
                                    .fullScroll(HorizontalScrollView.FOCUS_RIGHT);
                        }
                    });
        }

问候
MGD

Regards MGD

推荐答案

是layoutlistener有创建您的滚动视图时,所有的方式滚动视图以正确的?如果是这样你应该然后删除您onGlobalLayout函数中的事件侦听器,否则一旦进入奠定了它会向右滚动。

is your layoutlistener there to scroll your view all the way to the right when your scrollview is created? If so you should then remove the event listener inside your onGlobalLayout function, otherwise it will scroll right whenever it gets laid out.

这篇关于滚动型卧式全向右滚动注重与ViewTreeObserver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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