private fun showOrhide(//收缩部分        linearLayout: LinearLayout,        //旋转箭头        taskDetailArrow: RelativeLayout    ) {        val scrollView = binding.scrollView        val rect = Rect()        linearLayout.getGlobalVisibleRect(rect)        val arrow = taskDetailArrow.getChildAt(1)        if (linearLayout.visibility == View.VISIBLE) {            arrow.rotation = 180f            ObjectAnimator.ofFloat(                linearLayout,                "translationY",                0.0f, -linearLayout.measuredHeight.toFloat()            ).apply {                duration = 500                interpolator = AccelerateInterpolator()                start()            }.addListener(object : Animator.AnimatorListener {                override fun onAnimationRepeat(animation: Animator?) {                }                override fun onAnimationEnd(animation: Animator?) {                    linearLayout.visibility = View.GONE                    scrollView.post {                        scrollView.smoothScrollTo(0, rect.bottom);                    }                }                override fun onAnimationCancel(animation: Animator?) {                }                override fun onAnimationStart(animation: Animator?) {                }            })        } else {            arrow.rotation = 0f            ObjectAnimator.ofFloat(                linearLayout,                "translationY",                -linearLayout.measuredHeight.toFloat(), 0.0f            ).apply {                duration = 500                interpolator = AccelerateInterpolator()                start()            }.addListener(object : Animator.AnimatorListener {                override fun onAnimationRepeat(animation: Animator?) {                }                override fun onAnimationEnd(animation: Animator?) {                    linearLayout.visibility = View.VISIBLE                    scrollView.post {                        scrollView.smoothScrollTo(0, rect.bottom);                    }                }                override fun onAnimationCancel(animation: Animator?) {                }                override fun onAnimationStart(animation: Animator?) {                }            })        }

根据传入的View的visibility来执行收缩或者展开,scrollView不是找不到而是最外层布局哦。

更多相关文章

  1. ZZ android am命令
  2. 第32章、日期对话框DatePickerDialog(从零开始学Android)
  3. Android(安卓)带有弹出收缩动画的扇形菜单实例
  4. Android之getSystemService
  5. android 带箭头的textview文字伸缩效果
  6. android 如何优雅地给Activity和Fragement传入参数
  7. android am命令用法
  8. Android缺少awk:安装busybox
  9. android am命令

随机推荐

  1. android 模拟器 hardWare 特征说明
  2. Android通过URL获取网络数据
  3. Android联网使用HttpClient 和HttpRespon
  4. Android(安卓)-- 网络管理分析
  5. FAQ02963]如何拦截来电,即在电话ring之前
  6. android有用代码片段(一)
  7. Android(安卓)Notification详解
  8. Android(安卓)图片加载框架Glide缓存原理
  9. Surface与SurfaceHolder.Callback
  10. 同一个Activity先后加载2个Layout,从layo