ScrollView 没有滚动到最底部 [英] ScrollView not scrolling to most bottom

查看:53
本文介绍了ScrollView 没有滚动到最底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的布局如下:

这里的 ScrollView 包含很多元素.

Here the ScrollView contains many element.

我的问题:上面布局中显示的 fotter 布局最初消失了,在复选框单击时,我会在滚动视图的底部显示和隐藏.当我使它可见时,它会在所有项目的底部可见,但是当我按顺序滚动到底部时,它不会滚动到最大

My Issue : The fotter layout as shown in above layout is initally gone and on checkbox click i m showing and hidding on bottom on scrollview . When i make it visible it gets visbile on bottom of all items but when i scroll to bottom progratically it not scrollling to fullest

mCkAddEssence.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                LinearLayout fotter=(LinearLayout)findViewById(R.id.fotter);

                if(isChecked==true)
                {
                    fotter.setVisibility(View.VISIBLE);
                    ScrollView scrool=(ScrollView)findViewById(R.id.scrollview);
                    scrool.smoothScrollTo(0, scrool.getBottom());

                }else
                {
                    fotter.setVisibility(View.GONE);

                }

            }
        });

在子元素上尝试过:

 fotter.setVisibility(View.VISIBLE);
 ScrollView scrool=(ScrollView)findViewById(R.id.scrollview);
 scrool.scrollTo(0,mCkAddEssence.getBottom());

但没有用.

推荐答案

根据 docsView#getBottom() 返回相对于其父级的位置.

According to docs, View#getBottom() returns position relative to its parent.

您正在 ScrollView 上调用 getBottom() 但 IMO 您应该在 ScrollView 的第一个(也是唯一一个)子节点中调用它.

You are calling getBottom() on the ScrollView but IMO you should call it in ScrollView's first (and the only one) child.

这篇关于ScrollView 没有滚动到最底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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