val cardStackView = findViewById<CardStackView>(R.id.card_stack_view)
cardStackView.layoutManager =CardStackLayoutManager()
cardStackView.adapter =CardStackAdapter()
Features
Manual Swipe
Automatic Swipe
CardStackView.swipe()
You can set custom swipe animation.
val setting =SwipeAnimationSetting.Builder()
.setDirection(Direction.Right)
.setDuration(Duration.Normal.duration)
.setInterpolator(AccelerateInterpolator())
.build()
CardStackLayoutManager.setSwipeAnimationSetting(setting)
CardStackView.swipe()
Cancel
Manual swipe is canceled when the card is dragged less than threshold.
Rewind
CardStackView.rewind()
You can set custom rewind animation.
val setting =RewindAnimationSetting.Builder()
.setDirection(Direction.Bottom)
.setDuration(Duration.Normal.duration)
.setInterpolator(DecelerateInterpolator())
.build()
CardStackLayoutManager.setRewindAnimationSetting(setting)
CardStackView.rewind()
Overlay View
Value
Sample
Left
Right
Put overlay view in your item layout of RecyclerView.
<FrameLayoutandroid:id="@+id/left_overlay"android:layout_width="match_parent"android:layout_height="match_parent">
<!-- Set your left overlay -->
</FrameLayout>
Value
Layout ID
Left
left_overlay
Right
right_overlay
Top
top_overlay
Bottom
bottom_overlay
Overlay Interpolator
You can set own interpolator to define the rate of change of alpha.
You should NOT call RecyclerView.Adapter.notifyDataSetChanged for paging because this method will reset top position and maybe occur a perfomance issue.
Reloading
You can implement reloading by calling RecyclerView.Adapter.notifyDataSetChanged.
Copyright 2018 yuyakaido
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.