1

我有一个列表视图,并且想在单击它时更改项目的高度,并且单击的项目会转到屏幕的中心。当点击顶部的时候,item向下增加了高度,看起来还可以,但是问题是,点击底部的时候,view也是向下增加的,当item低于屏幕中心时,怎么能向上呢?

主要代码是:

Animation a = new Animation(){
        @Override
        protected void applyTransformation(float interpolatedTime, 
                                                     Transformation t) {
            v.getLayoutParams().height = (int)(0.5*mHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    a.setDuration(2000);
    v.startAnimation(a);

}

有人有什么想法吗?提前致谢。

4

1 回答 1

0

您应该检查smoothScrollBy,smoothScrollToPosition和其他用于滚动的方法。主要思想是使用向下滚动,使您的视图完全可见。为此,您必须计算需要滚动多少才能使项目可见。

于 2013-07-21T13:44:57.480 回答