Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to disable fading that a viewPager has scroll to edges?

Scrollable views such as the ListView have a fade blue effect along the edges where there is no content and scroll to the end. How can I close the effect?

at listview i can use :

 setHorizontalFadingEdgeEnabled(false);  android:fadingEdge="none"  android:requiresFadingEdge="none" 

but at the viewPager not useful,can give me some advice

like image 717
pengwang Avatar asked Sep 10 '13 10:09

pengwang


People also ask

How do I stop ViewPager from scrolling?

A simple solution is to create your own subclass of ViewPager that has a private boolean flag, isPagingEnabled . Then override the onTouchEvent and onInterceptTouchEvent methods. If isPagingEnabled equals true invoke the super method, otherwise return .

How do I stop ViewPager from sliding on Android?

To enable / disable the swiping, just overide two methods: onTouchEvent and onInterceptTouchEvent . Both will return "false" if the paging was disabled. You just need to call the setPagingEnabled method with false and users won't be able to swipe to paginate.

How does ViewPager2 work?

ViewPager2 uses FragmentStateAdapter objects as a supply for new pages to display, so the FragmentStateAdapter will use the fragment class that you created earlier. Create an activity that does the following things: Sets the content view to be the layout with the ViewPager2 .

What is ViewPager2 in Android studio?

ViewPager2 supports paging through a modifiable collection of fragments, calling notifyDatasetChanged() to update the UI when the underlying collection changes. This means that your app can dynamically modify the fragment collection at runtime, and ViewPager2 will correctly display the modified collection.


2 Answers

I have a solution:

android:overScrollMode="never" 

Now everything is OK. I found the solution here.

like image 64
pengwang Avatar answered Oct 11 '22 20:10

pengwang


 viewPager2.getChildAt(0)?.overScrollMode = RecyclerView.OVER_SCROLL_NEVER 
like image 25
HUAN XIE Avatar answered Oct 11 '22 19:10

HUAN XIE