Add a fixed button inside scrollview that is visible even when scrolling

enter image description here I want to make a view (the button actually) that is inside the scrollview, but when the user scolls down and the button goes up, it only moves up until it reaches the top of the visible screen and then remains there as a fixed caption, until the user scrolls again and then returns to its original position.

I gave screens for a better understanding.

enter image description here

+8
android
source share
2 answers

One way to solve this problem is to copy the same view outside the scroll bar and keep it hidden. Just to make it visible when the old button looks again.

@Override public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) { Rect scrollBounds = new Rect(); scrollView.getHitRect(scrollBounds); if (mPriceBtn.getLocalVisibleRect(scrollBounds)) { // View is within the visible window mPriceHiddenBtn.setVisibility(View.GONE); } else { // View is not within the visible window //mPriceBtn.setY(y); mPriceHiddenBtn.setVisibility(View.VISIBLE); } } 
+6
source share

Check out this tutorial . This is about an ActionBar with similar behavior created by ode for Google’s own Android developers. I guess you can find most of what you need.

0
source share

All Articles