Breno
Breno

Reputation: 1

Detect when screen is scrolling?

Here on my app I've got a small surfaceView that displays the camera preview. This surfaceView is put in a FrameLayout that is put in a ScrollView, alltogether with other components (like buttons, textViews and such). The thing is, that when i scroll the screen, the surfaceView leaves a black hole where it was, and this black hole is only filled when the screen is redrawn, so, I'd like to redraw the screen on each scrolling step (yes, I am willing to pay the performance trade off, if there's no other way). Someone has any ideas?

Upvotes: 0

Views: 768

Answers (1)

Lukas Hanacek
Lukas Hanacek

Reputation: 1364

extend your scrollview and put there

private OnScrollListener onScrollListener;

    public interface OnScrollListener {
        public void onScroll();
    }

@Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        if (onScrollListener != null) {
            onScrollListener.onScroll();
        }
        super.onScrollChanged(l, t, oldl, oldt);
    }

public void setOnScrollListener(OnScrollListener lst) {
        this.onScrollListener = lst;
    }

then you can listen for scrolling

scrollRoot.setOnScrollListener(new OnScrollListener() {
            @Override
            public void onScroll() {
                //do something
            }
        });

Upvotes: 1

Related Questions