在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):wasabeef/recyclerview-animators开源软件地址(OpenSource Url):https://github.com/wasabeef/recyclerview-animators开源编程语言(OpenSource Language):Kotlin 99.6%开源软件介绍(OpenSource Introduction):RecyclerView AnimatorsRecyclerView Animators is an Android library that allows developers to easily create RecyclerView with animations. Please feel free to use this. Features
DemoItemAnimatorAdaptersHow do I use it?SetupGradleOn your module's dependencies {
// Kotlin
implementation 'jp.wasabeef:recyclerview-animators:4.0.2'
} Also make sure that the
ItemAnimatorStep 1Set RecyclerView ItemAnimator. val recyclerView = findViewById<RecyclerView>(R.id.list)
recyclerView.itemAnimator = SlideInLeftAnimator() val recyclerView = findViewById<RecyclerView>(R.id.list)
recyclerView.itemAnimator = SlideInUpAnimator(OvershootInterpolator(1f)) Step 2Please use the following
fun remove(position: Int) {
dataSet.removeAt(position)
notifyItemRemoved(position)
}
fun add(text: String, position: Int) {
dataSet.add(position, text)
notifyItemInserted(position)
} Advanced Step 3You can change the durations. recyclerView.itemAnimator?.apply {
addDuration = 1000
removeDuration = 100
moveDuration = 1000
changeDuration = 100
} Advanced Step 4Change the interpolator. recyclerView.itemAnimator = SlideInLeftAnimator().apply {
setInterpolator(OvershootInterpolator())
} Advanced Step 5By implementing AnimateViewHolder, you can override preset animation. So, custom animation can be set depending on view holder. class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), AnimateViewHolder {
override fun preAnimateRemoveImpl(holder: RecyclerView.ViewHolder) {
// do something
}
override fun animateRemoveImpl(holder: RecyclerView.ViewHolder, listener: ViewPropertyAnimatorListener) {
itemView.animate().apply {
translationY(-itemView.height * 0.3f)
alpha(0f)
duration = 300
setListener(listener)
}.start()
}
override fun preAnimateAddImpl(holder: RecyclerView.ViewHolder) {
itemView.setTranslationY(-itemView.height * 0.3f)
itemView.setAlpha(0f)
}
override fun animateAddImpl(holder: RecyclerView.ViewHolder, listener: ViewPropertyAnimatorListener) {
itemView.animate().apply {
translationY(0f)
alpha(1f)
duration = 300
setListener(listener)
}.start()
}
} AnimatorsCool
Scale
Fade
Flip
Slide
RecyclerView.AdapterStep 1Set RecyclerView ItemAnimator. val recyclerView = findViewById<RecyclerView>(R.id.list)
recyclerView.adapter = AlphaInAnimationAdapter(MyAdapter()) JavaRecyclerView recyclerView = findViewById(R.id.list);
recyclerView.setAdapter(new AlphaInAnimationAdapter(MyAdapter()); Advanced Step 2recyclerView.adapter = AlphaInAnimationAdapter(MyAdapter()).apply {
// Change the durations.
setDuration(1000)
// Change the interpolator.
setInterpolator(vershootInterpolator())
// Disable the first scroll mode.
setFirstOnly(false)
} JavaAlphaInAnimationAdapter alphaInAnimationAdapter = new AlphaInAnimationAdapter(new MyAdapter());
alphaInAnimationAdapter.setDuration(1000);
alphaInAnimationAdapter.setInterpolator(new OvershootInterpolator());
alphaInAnimationAdapter.setFirstOnly(false); Advanced Step 3Multiple Animations val alphaAdapter = AlphaInAnimationAdapter(MyAdapter())
recyclerView.adapter = ScaleInAnimationAdapter(alphaAdapter) JavarecyclerView.setAdapter(new ScaleInAnimationAdapter(alphaInAnimationAdapter)); AdaptersAlpha
Scale
Slide
Applications using RecyclerView AnimatorsPlease ping me or send a pull request if you would like to be added here.
Developed ByDaichi Furiya (Wasabeef) - [email protected] ContributionsAny contributions are welcome! ContributersThanks
License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论