RecyclerView展开/折叠太快

时间:2019-06-18 09:10:25

标签: android android-animation

我的RecyclerView包含各种类型的项目。其中一种类型具有TextView标题和用于显示列表的RecyclerView。单击标题将填充/取消填充RecyclerView,从而对其进行扩展/折叠。

我想我注意到一个展开/折叠动画,但是它非常快。问题是如何放慢速度使其更引人注意?

代码:

...
itemView.showIncludedCountriesTextAndArrowLayout.setOnClickListener {

    val whatCountriesAreIncludedLayout: ConstraintLayout = itemView.findViewById(R.id.whatCountriesAreIncludedLayout)

    if (countryGridAdapter?.itemCount == 0) {
        itemView.upOrDownArrowImageView.setImageResource(R.drawable.ic_up_arrow_32dp)
        itemView.showTheIncludedCountriesTextView.text = mobileSubscriptionSiteCoreSectionData.countriesListCollapseText

        countryGridAdapter.updateList(mobileSubscriptionSiteCoreSectionData.countryList)

        // Bottom margin.
        val layoutParams = whatCountriesAreIncludedLayout.layoutParams as RecyclerView.LayoutParams
        layoutParams.bottomMargin = context.resources.getDimensionPixelSize(R.dimen.countriesIncludedVisibleList)
        whatCountriesAreIncludedLayout.layoutParams = layoutParams

        recyclerView.requestLayout()
        recyclerView.invalidate()

        onShowHideListViewClickListener.onClick(it, true, viewHolder.adapterPosition,
                (itemView.showIncludedCountriesTextAndArrowLayout.top +
                        itemView.showIncludedCountriesTextAndArrowLayout.paddingTop +
                        itemView.showIncludedCountriesTextAndArrowLayout.paddingBottom) * -1)

    } else {
        itemView.upOrDownArrowImageView.setImageResource(R.drawable.ic_down_arrow_32dp)
        itemView.showTheIncludedCountriesTextView.text = mobileSubscriptionSiteCoreSectionData.countriesListExpandText

        countryGridAdapter?.updateList(listOf())

        // Bottom margin.
        val layoutParams = whatCountriesAreIncludedLayout.layoutParams as RecyclerView.LayoutParams
        layoutParams.bottomMargin = 0
        whatCountriesAreIncludedLayout.layoutParams = layoutParams

        recyclerView.requestLayout()
        recyclerView.invalidate()

        onShowHideListViewClickListener.onClick(it, false)
    }
}
...

Here is a short video of the current behavior

0 个答案:

没有答案