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)?
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With