animateLayoutChanges does not work well with nested layout?

前端 未结 5 764
既然无缘
既然无缘 2020-12-07 18:57

I have a nested layout like the following:

      
        
              


        
5条回答
  •  时光取名叫无心
    2020-12-07 19:06

    As a Kotlin Extension

    fun ViewGroup.forceLayoutChanges() {
        layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
    }
    

    Usage

    someContainer.forceLayoutChanges()
    

    Notes:

    In my experience, this happens when the container is a deep nested layout. For some reason android:animateLayoutChanges="true" just doesn't work, but using this function will force it to work.

提交回复
热议问题