I have a ScrollView and GridView in it, I want to put a TextView on top of GridView but it must not be seen until user scrolls to it. I thought about negative margins but I couldn't find a solution how to use scroll to get this view when on negative margin.
So basicaly : The only seen thing should be gridView, but when user is on top of gridView and pulls up, he should see a TextView.
edit: the whole point of this is that I want to made pull-to-refresh out of this. I don't want to use popular on the internet libary because it doesn't work way I want.
EDIT 2:
I got the answer but it is not fully what I try to achieve. I want to smoothly show hidden TextView (just like in pull-to-refresh solutions) and setVisibility makes it quick and without any smoothnes. Here is my code :
XML :
<com.tas.android.quick.ui.controls.LockableScrollView
android:id="@+id/scrollView"
android:fillViewport="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/pullText"
android:text="some text" />
<com.tas.android.quick.ui.controls.ExpandableGridView
android:id="@+id/gridview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clipToPadding="false"
android:drawSelectorOnTop="true"
android:fadingEdge="none"
android:gravity="top"
android:horizontalSpacing="@dimen/image_grid_hspacing"
android:listSelector="@drawable/selector_shadow"
android:numColumns="@integer/grid_num_cols"
android:paddingBottom="50dp"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbars="none"
android:scrollingCache="true"
android:smoothScrollbar="false"
android:stretchMode="columnWidth"
android:verticalSpacing="@dimen/image_grid_vspacing"
android:visibility="visible" />
</LinearLayout>
</com.tas.android.quick.ui.controls.LockableScrollView>
and code:
textview = (TextView) findViewById(R.id.pullText);
textview.setVisibility(View.VISIBLE);
scrollView = (LockableScrollView) findViewById(R.id.scrollView);
scrollView.setScrollingEnabled(false);
...
gridView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
switch(scrollState) {
case 2: // SCROLL_STATE_FLING
//hide button here
textview.setVisibility(View.VISIBLE);
break;
case 1: // SCROLL_STATE_TOUCH_SCROLL
//hide button here
textview.setVisibility(View.GONE);
break;
case 0: // SCROLL_STATE_IDLE
//show button here
textview.setVisibility(View.GONE);
break;
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
}
}
}
});