ScrollView无法滚动到最底部

时间:2015-12-16 12:37:30

标签: android scrollview

我的布局如下:

enter image description here

这里ScrollView包含许多元素。

我的问题:上面布局中显示的fotter布局最初消失了,然后在复选框上单击我在滚动视图底部显示和隐藏。当我让它可见时,它会在所有项目的底部变得可见,但是当我逐步滚动到底部时它不会滚动到最充分的

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());

但没有奏效。

1 个答案:

答案 0 :(得分:0)

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

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