Comments (9)
You can rewrite the setStyle3() method in MainActivity, and change the setTransformerToBack into this, which is similar to DefaultTransformerToFront, but reverse the rotationX movement:
mCardView.setTransformerToBack(new AnimationTransformer() {
@Override
public void transformAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {
int positionCount = fromPosition - toPosition;
float scale = (0.8f - 0.1f * fromPosition) + (0.1f * fraction * positionCount);
view.setScaleX(scale);
view.setScaleY(scale);
view.setRotationX(fraction == 1 ? 0 : 180 * fraction);
if (fraction < 0.5) {
view.setTranslationY(-cardHeight * (0.8f - scale) * 0.5f - cardWidth * 0.02f
* fromPosition - cardHeight * fraction);
} else {
view.setTranslationY(-cardHeight * (0.8f - scale) * 0.5f - cardWidth * (0.02f *
fromPosition - 0.02f * fraction * positionCount) - cardHeight * (1 - fraction));
}
}
@Override
public void transformInterpolatedAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {
}
});
from android-infinitecards.
Below is the total view of setStyle3() method after rewrite:
from android-infinitecards.
You can test by press "change" button once and then press "next" button, which was swinging out to the side before rewrite. Hope this can help you.
from android-infinitecards.
Fantastic, that's perfect, thanks so much.
Another question if it's ok: How can I alter the amount of overlap on the cards behind the front one? I'd like more of each card to be visible, so that the title of my item can be seen be the user.
from android-infinitecards.
In this case, you'll need to recalculate the TranslationY in each Transformer.
If I understand your question correctly, try add the code below at the end of onCreate() method:
mCardView.setTransformerAnimAdd(new AnimationTransformer() {
@Override
public void transformAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {
fromPosition = toPosition + 1;
int positionCount = fromPosition - toPosition;
float scale = (0.8f - 0.1f * fromPosition) + (0.1f * fraction * positionCount);
view.setScaleX(scale);
view.setScaleY(scale);
view.setTranslationY(-cardHeight * (0.8f - scale) * 0.5f - cardWidth * (0.05f *
fromPosition - 0.05f * fraction * positionCount));
view.setAlpha(fraction);
}
@Override
public void transformInterpolatedAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {
}
});
from android-infinitecards.
from android-infinitecards.
Unfortunately, that method isn't public, I can't compile that!
from android-infinitecards.
Yes you can. But what you need to do is not to modify the code in DefaultTransformerXXX, but to customize your own AnimationTransformer and call setTransformerXXX method of the InfiniteCardView.
from android-infinitecards.
Thanks. I had to import the code directly into my project, and change all the default transformers. I've made a constant for the top gap, so it's now configurable.
from android-infinitecards.
Related Issues (20)
- Is it possible for the cards to be angled by default? HOT 5
- only show one card to view HOT 2
- java.lang.NullPointerException: HOT 1
- Does it support manual sliding HOT 1
- Can I implement swipe action on the items. HOT 12
- Show selected items from list on the view HOT 1
- View taking padding by default HOT 5
- Delay in swap animation due to late UI rendering. HOT 22
- How to change the size of each card? HOT 1
- How can i replace an element in an array keeping style?
- Can we add swipe action in cards? HOT 3
- 如果要循环滚动,怎么是性能消耗最低 HOT 1
- Multiple card switches with 1 click?
- how to reverse the layout HOT 1
- 关于动画效果 HOT 19
- 这个可以左右滑动么? HOT 4
- 动画效果问题 HOT 4
- Remove a card from stack HOT 1
- 请问可以固定显示的个数吗? HOT 1
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-infinitecards.