I’ve been trying to figure out how to create a refresh mechanism that works differently from the typical pull-down approach. Instead of the usual hidden row that gets revealed when you pull down, I want to show an animated overlay message that appears on top of the toolbar area.
The animation should include a moving horizontal progress line that indicates the refresh is happening. I’ve looked through the Android documentation but I’m not sure if this is something built into the framework or if it requires custom implementation.
Has anyone implemented this kind of refresh pattern before? What would be the best approach to create this overlay animation effect?
u might wanna check out a custom overlay view on your activity. i did smth similar with a FrameLayout - first place the overlay just above the screen (like a negative translationY), then animate it down with the pull gesture. for the progress, try a horizontal ProgressBar in indeterminate mode or create a custom animated drawable. just make sure you’re detecting gestures right.
I built something similar for a client recently. You’re correct in noting that this feature isn’t available in the standard framework, which means you’ll have to create a custom solution yourself. What worked well for me involved designing a custom ViewGroup that sits above the main content, starting just outside of the visible area. For the animation, I utilized a combination of TranslateAnimation to slide the overlay into view, and ObjectAnimator for a custom drawable representing the progress line. A key point is to intercept touch events in your main content and determine the pull distance to activate the overlay. Ensure to also address edge cases carefully, particularly if users release their pull mid-action. Additionally, consider using ValueAnimator for the progress line for smoother control versus directly adjusting drawable bounds.
I dealt with this same issue six months ago. Here’s what worked for me: Use a custom LinearLayout at the top of your root container, set to visibility GONE initially. When you detect the pull gesture, flip it to VISIBLE and animate both alpha and translationY at the same time - gives you that smooth entrance. Skip the standard ProgressBar for the indicator. Just use a simple View and animate the width changes with ViewPropertyAnimator. The gesture detection was the hardest part. I ended up overriding dispatchTouchEvent in my main activity to grab the pull motion before it hits the scrollable content. Don’t forget to handle config changes or you’ll lose your animation state when the screen rotates.