Snap content on top of scrollview when scrolling
===

I wasn't sure how to ask the question, but here is the explanations/description:

All the view's content is inside a scrollview. There's one a LinearLayout inside this ScrollView that I want to: (1) scroll with the view, but when it gets to the top (2) "float", or "stick" while the rest of the content continues to scroll.

Upon scrolling down, it would return to it's original position, scrolling with the rest of the content. 

I've created a class the extends ScrollView and created a "onScrollListener". All that is working, that way I can get the Y offset and all. 

I'm trying to do something along the lines, but not working:

    public void onScrollChanged(ObservableScrollView scrollView, int x, int y,
			int oldx, int oldy) {
		
		int diff = y+112; //ignore this magic number.
		Log.d("Y:",String.valueOf(diff));
		Log.d("OldY:",String.valueOf(oldy+diff));
		Log.d("ScrollViewY:",String.valueOf((scrollView.getY()+diff)));
		
		
		
		if(diff >= contentView.getY()){	
			//persist Y for content view, at the top of screen
            contentY.setY(0);
    
			
		}
		
		
	}

The code above does not work, since my view continues to scroll off the screen instead of sticking to the top. 

This gotta be doable, since recently the same result was achieved in iOS by a friend of mine with the following lines of code in ObjectiveC:

    if(scrollView.contentOffset.y >= buttonBarViewFrame.origin.y)
       buttonBarView.frame = CGRectMake(buttonBarViewFrame.origin.x, scrollView.contentOffset.y, buttonBarViewFrame.size.width, buttonBarViewFrame.size.height);

Thanks gents!
