[Solve the problem that viewpager does not slide smoothly on the screen] set the page turning distance of viewpager.

Source: Internet
Author: User

In the project, a viewpager + fragment slide page flip is performed, and the test on the simulator and Xiaomi mobile phone is also normal. However, when I switched to a screen test of over 4.7, I found that the slide always failed.

Because the default sliding policy of the system is that the page is displayed only when the user slides more than half a screen. After finding many methods on the Internet, the system fails. I thought it was because I used viewpagerindicator. Then viewpagerindicatorCodeAfter deletion, there was no improvement. In fact, viewpager's sliding paging root viewpagerindicator had no semi-gross relationship. All are managed by the system.

 

Then I tried to rewrite the ontouch and setonpagechangelistener methods. Although they can achieve the desired effect, they did not inherit the system animation. The setcurrentindex () method is ugly. I don't want to rewrite pageradapter either. After finding n examples on the internet, I found that some examples slide abnormally smoothly, and there is no difference in the analysis code, and the code I wrote is also exceptionally smooth after I copied it, this proves that it is not a problem with the code written by brother.

 

After a day of struggle, I finally thought about the V4 support package problem? However, the two jar extension packages use V4. After trying to replace the V4 extension package, the problem is solved !!!

 

 

That is to say, the reason why viewpager does not slide smoothly on the big screen and cannot flip the page because Google modified the viewpager slide policy in the V4 package, the simplest way is to replace it with the old V4 package!

The old V4 package is attached below. I just want to say that Google is so bad. If I modify the V4 package, I will not say anything... This small bug has been ruined for two days... but it will also cause some problems, that is, the old V4 package lacks some new methods. This requires you to weigh the costs of your project.

 

Http://download.csdn.net/detail/h3c4lenovo/5786767

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.