Scrollview: check if a view is visible on screen or not

android, android-scrollview

Solution

To check if the view is fully/partially visible you can use :

boolean isViewVisible = view.isShown();

To determine if it is fully visible use below approach:

Rect rect = new Rect();
if(view.getGlobalVisibleRect(rect) 
    && view.getHeight() == rect.height() 
    && view.getWidth() == rect.width() ) {
    // view is fully visible on screen
}

Problem

I have a ScrollView defined like: ``` <ScrollView ... .../> <LinearLayout ... ...> <!-- content --> </LinearLayout> </ScrollView> ``` And I fill the LinearLayout dynamically with some ImageViews. Now, is there a way to check when an ImageView gets visible or invisible (for example when i scroll down)?

Original source

Related problems