Comments (5)
大佬,有demo吗
from vegalayoutmanager.
@7hunder
上边代码也差不多了,你继承LinearLayoutManager 就完事了。也没啥demo吧,recyclerView该咋用咋用,就是layoutManager用这个就行了。
`import android.content.Context
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
class LayoutManagerScaleFirst:LinearLayoutManager{
constructor(context: Context?) : super(context)
constructor(context: Context?, orientation: Int, reverseLayout: Boolean) : super(context, orientation, reverseLayout)
private var oldChild0:View?=null;
private val scaleMinFactor=0.7f //from 0 to 1
override fun scrollVerticallyBy(dy: Int, recycler: RecyclerView.Recycler, state: RecyclerView.State?): Int {
val result=super.scrollVerticallyBy(dy, recycler, state)
if(childCount>1){
val child1=getChildAt(1)
val child0=getChildAt(0)
if(oldChild0!=null&&oldChild0!=child0){
resetChild(oldChild0!!)
}
oldChild0=child0
val scale=scaleMinFactor+(1-scaleMinFactor)*(child1.top)/getDecoratedMeasuredHeight(child1)
println("scrollVerticallyBy====${scale}==childCount=${childCount}===${getChildAt(0).height}====${getChildAt(1).top}")
viewAnimate(child0,scale,getDecoratedMeasuredHeight(child1)-child1.top.toFloat())
if(scale<scaleMinFactor){
resetChild(child0)
removeAndRecycleView(child0,recycler)
}
}
return result
}
private fun resetChild(child:View){
viewAnimate(child,1f,0f)
}
private fun viewAnimate(child: View,factor:Float,transY:Float){
child.apply {
pivotX=this.width/2f
pivotY=this.height/1f
scaleX=factor;
scaleY=factor;
alpha=factor;
translationY=transY
}
}
}`
from vegalayoutmanager.
感谢大佬
from vegalayoutmanager.
加上margin或者padding后能看到顶上缩小的view
from vegalayoutmanager.
不知道你说的啥样子,上下margin用decoration就行,左右的margin应该没啥影响吧,我这里是滑动的效果图,没看出有啥问题。 或者你具体说下,给谁添加margin?另外我就是个菜鸟。
https://www.jianshu.com/p/42f9997e3ce0
from vegalayoutmanager.
Related Issues (20)
- Problems with space between items. HOT 2
- 出现You must override smoothScrollToPosition to support smooth scrolling HOT 3
- Horizontal recyclerview HOT 1
- RecyclerView as Viewpager with PagerSnapHelper HOT 1
- How to stop auto scroll item? HOT 1
- gradle 引入有问题
- (Illegal state Exception) Crash Issue Solved
- Recycler items gets invisible when scrolling often (API 21)
- How I can get findLastVisibleItemPosition like in LinearLayoutManager ?
- Fragment中使用什么都不展示 HOT 1
- how to snap it to next item only like viewpager HOT 1
- 加上分页后,显示不正确 HOT 1
- demo显示无内容 HOT 4
- Not visible any view on VegaLayoutManager HOT 8
- child view visibility
- how to add scrollbar to recyclerView?
- E/RecyclerView: You must override smoothScrollToPosition to support smooth scrolling
- recyclew+viewpager显示异常
- To solve the problem of viewpager: an instance of onflinglistener already set.解决ViewPager闪退问题。
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 vegalayoutmanager.