How to make the hide and show animation of custom view
NickName:Ker_ Jen Ask DateTime:2018-08-17T05:38:03

How to make the hide and show animation of custom view

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

More about “How to make the hide and show animation of custom view” related questions

How to make the hide and show animation of custom view

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...

Show Detail

Android: how to hide and then show View with animation effect?

I have similar question like this one: Update layout with the animation Basically: I have one vertical LinearLayout View with edittext, button and then list. I'd like to hide exittext after pressing

Show Detail

Android Animation Hide And Show View

I am learning about animations, can't find a good document on the net anyway I would like to do the following: Click button to hide view - works OK Click same button again to show view - Not OK The

Show Detail

Animation show and hide view in Swift

I have this function: func showwAndHideFilterMenu(category : Int) { if showFilterMenu == false{ UIView.animate(withDuration: 0.6, delay: 0, options: .curveEaseInOut, animations: { ...

Show Detail

hide and show animation jquery

How can I avoid the box animation of hide and show function? I want the hide to make the black div slowly disappear without the box animation. $("#hide").click(function(){ $("#view").hide(...

Show Detail

Custom View make visible an hide

I am writing a cocoa app. I have a hidden custom View. I want to make it visible by clicking show and I want to hide it by clicking hide. My idea was to make it like in a window. my code: - (IBAct...

Show Detail

Show/Hide view with animation in android

I want to hide and show view with animation after the user touches on screen alternatively. but I have not any idea how to do that. Can anybody help me, please? I get the hight of view here int

Show Detail

Hide and Show View after animation is finished in SwiftUI

How to hide and show an Image/View after an animation is done in SwiftUI. Image(systemName: "arrow.2.circlepath.circle.fill") .rotationEffect(.degrees(spin ? 360 : 0)) .animation(Animation.

Show Detail

How to hide/show UIView with animation in iPhone

I want to show UIView after button pressed with animation,I can show the view but I am unable to hide it again pressed that button.Here is my code to show/hide the view. To Show the UIView :

Show Detail

Android: show/hide a view using an animation

I've been looking through many google results / questions on here to determine how to show/hide a view via a vertical animation, but I can't seem to find one that's exactly right or not too vague. I

Show Detail