Comments (5)
check the below code and change scale and translate parameters. Or you can change in layout with margin or padding.
layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener() {
@Override
public ItemTransformation transformChild(@NonNull View child, float itemPositionToCenterDiff, int orientation) {
float scale = (float) (2 * (2 * -StrictMath.atan(Math.abs(itemPositionToCenterDiff) + 1.0) / Math.PI + 1));
float translateY;
float translateX;
if (CarouselLayoutManager.VERTICAL == orientation) {
final float translateYGeneral = child.getMeasuredHeight() * (1 - scale) * 2 * 1.15f;
translateY = Math.signum(itemPositionToCenterDiff) * translateYGeneral;
translateX = 0;
} else {
final float translateXGeneral = child.getMeasuredWidth() * (1 - scale) * 2 * 1.15f;
translateX = Math.signum(itemPositionToCenterDiff) * translateXGeneral;
translateY = 0;
}
//CommonHelper.log("itemPositionToCenterDiff: " + itemPositionToCenterDiff + ", scale: " + scale + ", x: " + translateX + ",y: " + translateY);
scale = 1;
if (-0.5 < itemPositionToCenterDiff && itemPositionToCenterDiff < 0.5) {
child.setAlpha(1f);
} else {
child.setAlpha(0.5f);
}
return new ItemTransformation(scale, scale, translateX, translateY);
}
});
from carousellayoutmanager.
thank you for this block of code @onka13 and now my problem is when ever i scroll the items the image at the center is a bit jumpy/jerky.
from carousellayoutmanager.
@erylljoy24 could you please share your code. (PostLayoutListener)
from carousellayoutmanager.
@onka13 i used this block of code
`public ItemTransformation transformChild(@nonnull View child, float itemPositionToCenterDiff, int orientation) {
final float scale = (float) (2 * (2 * -StrictMath.atan(Math.abs(itemPositionToCenterDiff) + 1.20) / Math.PI + 1));
final float translateY;
final float translateX;
if (CarouselLayoutManager.VERTICAL == orientation) {
final float translateYGeneral = child.getMeasuredHeight() * (1 - scale) * 2 * .50f;
translateY = Math.signum(itemPositionToCenterDiff) * translateYGeneral;
translateX = 0;
} else {// 0.60
final float translateXGeneral = (float) ((0 - scale) * .20 * .50f);
translateX = Math.signum(itemPositionToCenterDiff) * translateXGeneral;
translateY = 0;
}
return new ItemTransformation(scale, scale, translateX, translateY);
}`
i don't know why it caused a jumpy scroll
from carousellayoutmanager.
@erylljoy24 same issue i'm facing please help if you have solution
from carousellayoutmanager.
Related Issues (20)
- How enable auto scroll HOT 1
- 请问怎么设置缩放大小?How do I set the zoom size?
- 你好,可以设置子view的高度或缩小比例吗?
- Click Listener
- Number of item count while scrolling
- Fatal Exception: java.lang.NullPointerException Attempt to read from field 'androidx.recyclerview.widget.RecyclerView$ViewFlinger androidx.recyclerview.widget.RecyclerView.mViewFlinger' on a null object reference HOT 5
- how Switch to increase transparency during sliding
- Consider migrating from jcenter HOT 5
- All items can be in a position from top to bottom HOT 2
- Gradient Color Background Items
- How to add item fade effect HOT 1
- How to disable smoothScrollToPosition HOT 8
- My app cant open in my andorid after build the app HOT 7
- can't display image with using <androidx.recyclerview.widget.RecyclerView>
- One swipe, many scrolling
- how does it look like ViewPager
- How to correctly offset elements? HOT 1
- No item visible
- Set item selected on initialization HOT 1
- Have you achieve to add dot indicator to your Carousel ?
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 carousellayoutmanager.