CollapsingToolbarLayout expand only when at the top

后端 未结 5 875
耶瑟儿~
耶瑟儿~ 2021-02-05 17:58

I have some problems with AppBarLayout and CollapsingToolbarLayout. This is what currently happens:

https://www.youtube.com/watch?v=z4yD8rmjSjU

The downwards scr

5条回答
  •  春和景丽
    2021-02-05 18:11

    I ended up moving the orange bar out of the CollapsingToolbarLayout and setting an OnOffsetChangedListener that changes the translationY of the top bar on the AppBarLayout.

    Setting the OnOffsetChangedListener:

    app_bar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appbar, offset ->
    
        topbar.translationY = Math.min(image.height.toFloat(),  - offset.toFloat())
    
    })
    

    Layout:

    
    
        
    
        
    
            
    
    
        
    
        
    
    
    
    
        
    
    
    

提交回复
热议问题