Skip to content Skip to sidebar Skip to footer

Need To Hide A Textview While Scrolling A Grid View

I'm trying to hide a textView while scrolling a grid view and make the same textview visible again when the user stops scrolling. Can anyone help me fixing this issue..?

Solution 1:

implement OnScrollListener and then inside the onScroll make the textView invisible and in the OnScrollStateChanged method check if the scroll stopped and make it visibile again

privateOnScrollListenermScrollListener=newOnScrollListener() {

    @OverridepublicvoidonScrollStateChanged(ViewGroup view, int scrollState) {
         if(scrollState == SCROLL_STATE_IDLE)
         {
                 textView.setVisibility = View.VISIBLE;       
         }

    @OverridepublicvoidonScroll(ViewGroup view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                 textView.setVisibility = View.INVISIBLE
    }
};

Solution 2:

You can use setVisibility in OnScrollListener

Example:

gridview.setOnScrollListener(newOnScrollListener() {
    @OverridepublicvoidonScrollStateChanged(AbsListView view, int scrollState) {

        if(scrollState == SCROLL_STATE_IDLE)
        {
            textview.setVisibility(View.VISIBLE);   
        }
    }

    @OverridepublicvoidonScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) {

        textview.setVisibility(View.GONE); 
    }
});

Hope it helps.

Solution 3:

gridView.setOnScrollListener(new OnScrollListener() {

@OverridepublicvoidonScrollStateChanged(AbsListView view, int scrollState) {

    if(scrollState == SCROLL_STATE_IDLE)
    {
        textview.setVisibility(View.VISIBLE);   
    }
}

@OverridepublicvoidonScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {

    textview.setVisibility(View.GONE); 
}

});

We use this code in my app and it work , I hope it will useful to you.

Solution 4:

Try this code:

privateOnScrollListenermScrollListener=newOnScrollListener() {

    @OverridepublicvoidonScrollStateChanged(ViewGroup view, int scrollState) {
        if(scrollState == SCROLL_STATE_IDLE)
        {
            tv.setVisibility(View.VISIBLE);
        }
    }
    @OverridepublicvoidonScroll(ViewGroup view, int firstVisibleItem, int visibleItemCount, int totalount)
    {
        tv.setVisibility(View.INVISIBLE);
    }

});

Solution 5:

Try this:

Private OnScrollListenermScrollListener=newOnScrollListener() {

@OverridepublicvoidonScrollStateChanged(ViewGroup view, int scrollState) {
         if(scrollState == SCROLL_STATE_IDLE)
     {
                 mTextView.setVisibility = View.VISIBLE;       
         }
@OverridepublicvoidonScroll(ViewGroup view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                 mTextView.setVisibility = View.INVISIBLE
    }
};

Post a Comment for "Need To Hide A Textview While Scrolling A Grid View"