相关疑难解决方法(0)

iOS喜欢Android上的滚动效果

我想在我的应用程序中实现类似iOS的反弹过度滚动效果.

我遇到了这个链接,建议创建一个自定义ScrollView.但问题是,当我快速上下滚动它工作正常但是一旦我拉动屏幕的底部或顶部它就会卡住而且效果不再起作用.

作为我想要实现的那种动画的一个例子,你可以看看这个:

这是我目前的代码:

public class ObservableScrollView extends ScrollView
{
    private static final int MAX_Y_OVERSCROLL_DISTANCE = 150;

    private Context mContext;
    private int mMaxYOverscrollDistance;

    public ObservableScrollView(Context context)
    {
        super(context);
        mContext = context;
        initBounceScrollView();
    }

    public ObservableScrollView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        mContext = context;
        initBounceScrollView();
    }

    public ObservableScrollView(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
        mContext = context;
        initBounceScrollView();
    }

    private void initBounceScrollView()
    {
        //get the density of the screen and do some maths …
Run Code Online (Sandbox Code Playgroud)

java animation android android-animation android-scrollview

8
推荐指数
2
解决办法
9682
查看次数