Task:
I wanna hide and show my view with animation.
Troubles:
First of all I tried to make it with changing view's visible (GONE, VISIBLE) (I use Transition API) but there were bugs with animation.
Then I tried to do it with scale animation but there was a bug with a hint in editText (child view).
My custom view which I wanna animate:
class SearchAdditionalView(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
private val transitionSet: TransitionSet by lazy {
val transitionSet = TransitionSet()
with(transitionSet) {
addTransition(ChangeBounds())
interpolator = DecelerateInterpolator()
duration = 200
}
transitionSet
}
init {
inflate(context, R.layout.include_search_navbar_addition, this)
}
fun toggle() {
visibility = View.VISIBLE
TransitionManager.beginDelayedTransition(parent as ViewGroup, transitionSet)
}
}
Question:
Are there good practices for this animation and how can I integrate it?
Copyright Notice:Content Author:「Ker_ Jen」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51885667/how-to-make-the-hide-and-show-animation-of-custom-view