安卓Kotlin 解决OverscrollableNestedScrollView在fragment中使用时无法正常下拉显示appbar的问题

只需在下拉动作结束之后手动展开appbar即可

package xxx.xxx

import android.content.Context
import android.util.AttributeSet
import com.akscorp.overscrollablescrollview.OverscrollableNestedScrollView
import kotlinx.android.synthetic.main.app_bar_main.*
import xxx.xxx.MainActivity.Companion.mainWeakReference

open class OverScrollView :OverscrollableNestedScrollView{
    
    
    constructor(context: Context) : super(context)

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)

    override fun isAchieveTop(): Boolean {
    
    
        val re = super.isAchieveTop()
        if(re) mainWeakReference?.get()?.appbar?.setExpanded(true)
        return re
    }
}

猜你喜欢

转载自blog.csdn.net/u011570312/article/details/108479760