Comments (2)
Hi I found the solution for the same.
By overriding the method below we can achieve this.
public void transformPage(View view, float position) {
if (position < -1) {
view.setAlpha(0);
} else if (position <= 0) {
view.setAlpha(1 + position);
view.setTranslationX(view.getWidth() * -position);
view.setTranslationZ(-1);
view.setScaleX(1);
view.setScaleY(1);
} else if (position <= 1) {
view.setAlpha(1);
view.setScaleX(1);
view.setScaleY(1);
view.setTranslationZ(1);
} else {
view.setAlpha(1);
}
}
from android-viewpager-transformers.
Hey I found the solution, you just have to find out from which side are you dragging and then pass it.
((ViewPager) fragmentViews).setPageTransformer(true, new DefaultTransformer(){
@Override
protected void onTransform(View view, float position) {
int a = Float.compare(position, 0.000000000f);
view.setTranslationX(a >= 0 ? 0f : -view.getWidth() * position);
view.setTranslationZ(a >= 0 ? 1 : -1);
}
@Override
protected void onPreTransform(View view, float position) {
final float width = view.getWidth();
int a = Float.compare(position, 0.000000000f);
view.setRotationX(0);
view.setRotationY(0);
view.setRotation(0);
view.setScaleX(1);
view.setScaleY(1);
view.setPivotX(0);
view.setPivotY(0);
view.setTranslationY(0);
if (!((CustomViewPager)fragmentViews).isFromLeftSwipe()) {
view.setTranslationX(a >= 0 ? width * position : 0f);
} else {
view.setTranslationX(a >= 0 ? 0f : -width * position);
}
if (hideOffscreenPages()) {
view.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
} else {
view.setAlpha(1f);
}
}
});
from android-viewpager-transformers.
Related Issues (19)
- Upload to maven
- Change the Readme.md file after deploy on maven central
- Typo in Readme HOT 1
- Missing License(s) HOT 1
- Button on ViewPager Child layout not clickable when DrawerFromBackTransformation is applied HOT 7
- There is a Fade In/Out effect? HOT 4
- Setting Animation Duration HOT 1
- how to do parallax transform HOT 1
- Vertical Stack HOT 3
- viewpager- vertical stack transformers
- How to make Stack transformation in opposite direction??? HOT 2
- Buttons on the back are clickable in FlipHorizontalTransformer HOT 1
- Tablayout click won't animate viewpager
- Class name typo
- Side pages visible in current page if full width
- Black/Empty content when using CubeOutTransformer HOT 1
- No such property: sonatypeRepo Error
- Some transformers failing hard according to offscreenpage limit for your view pager HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-viewpager-transformers.