How to discover that HorizontalScrollView has reached the end

I want when you reach the end, the right button will change color, when it reaches the beginning, the left button will change color, so I want to ask how to detect that HorizontalScrollView has reached the end.

+6
source share
1 answer
maxScrollX = horizontalScrollView.getChildAt(0).getMeasuredWidth()-horizontalScrollView.getMeasuredWidth(); if (horizontalScrollView.getScrollX() == 0) { lImageView.setImageResource(R.drawable.left_green); } else { lImageView.setImageResource(R.drawable.left); } if (horizontalScrollView.getScrollX() == maxScrollX) { rImageView.setImageResource(R.drawable.right_green); } else { rImageView.setImageResource(R.drawable.right); } 
+12
source

Source: https://habr.com/ru/post/910143/


All Articles