在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):arunkumar9t2/transition-x开源软件地址(OpenSource Url):https://github.com/arunkumar9t2/transition-x开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):Transition XKotlin DSL for choreographing Android Transitions
I highly recommend reading the introduction blog post on my blog. Download
allprojects {
repositories {
jcenter()
}
}
dependencies{
implementation 'in.arunkumarsampath:transition-x:1.1.0'
} IntroductionAs shown above, instead of creating XML files and later inflating them using With Transition X, the construction and usage can be greatly simplified with a For example: constraintLayout.prepareTransition {
fadeOut {
startDelay = 100
}
moveResize {
pathMotion = ArcMotion()
}
fadeIn()
+textView // Add textView as target using '+' operator
exclude<RecyclerView>() // Exclude all recyclerViews
ease {
standardEasing // Applies FastOutSlowInInterpolator
}
}
// Performing layout changes here will be animated just like
// calling TransitionManager.beginDelayedTransition() All blocks are type-safe and has IDE auto complete support thanks to Kotlin. Getting StartedWriting your first transitionTransitionSet's can be built programmatically like shown below. val transition = TransitionSet().apply {
addTransition(ChangeBounds().apply {
startDelay = 100
setPathMotion(ArcMotion())
})
} The Transition X equivalent would be: val transition = transitionSet {
moveResize {
startDelay = 100
pathMotion = ArcMotion()
}
} Some of the transition names are opinionated to better express their intent and promote clear code. Here Working with custom transitionsIn case you have a custom transition class and want to use with the DSL, it is easy to do so.
constraintLayout.prepareTransition {
customTransition<ChangeCardColor> {
+colorChangeCardView
}
}
Accessing custom propertiesIn addition to the common properties like constraintLayout.prepareTransition {
customTransition<ChangeCardColor> {
+colorChangeCardView
customProperties {
myProperty = "hi"
}
}
} Adding, removing and excluding targetsThe DSL provides simplified syntax to deal with targets by talking to
transitionSet {
+"TransitionName"
+userIconView
add(userIconView)
}
transitionSet {
-"TransitionName"
-userIconView
remove(userIconView)
}
transitionSet {
exclude<RecyclerView>()
exclude(R.id.accentBackground)
excludeChildren(constraintLayout)
} Interpolators
transitionSet {
moveResize()
slide()
interpolator = FastOutLinearInInterpolator()
}
transitionSet {
moveResize()
ease {
decelerateEasing
}
} Nesting transitionsOften, for fined grained transitions it it necessary to add different transition sets for different targets. It is simple to nest multiple transition sets just by using transitionSet {
auto {
+"View 1"
}
transitionSet {
moveResize()
slide()
+"View 2"
}
transitionSet {
sequentially()
fadeOut()
moveResize()
fadeIn()
}
} Adding listeners to transitionsTransition-X makes it easy to react to Example: rootCoordinatorLayout.prepareTransition {
onStart {
// Transition Started!
}
moveResize {
+image1
}
onEnd {
// Transition Ended!
}
} Additional transitionsThe library packages additional transitions not present in the support library and the plan is to add more commonly used transitions to provide a full package. Currently the following transitions are packaged:
SamplesTasks
ContributionsContributions are welcome! I would greatly appreciate creating an issue to discuss major changes before submitting a PR directly. How you can help:
License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论