Android CollapsingToolbarLayout Title background

前端 未结 4 1322
無奈伤痛
無奈伤痛 2020-12-12 17:31

I\'m working with the CollapsingToolbarLayout from the new Android Design Support Library.

I have set its title and it is working fine, the only problem I still have

4条回答
  •  甜味超标
    2020-12-12 17:59

    That's a lot of work do achieve here by writing that much of code. I achieved that by 2 ways.

    1 A simple workaround by using a View with TransparentBlack color
    CODE>>

    Code explaination:
    1 The CollapsingToolbarLayout has a style with only a text size.
    2 Default CollapsingToolbarLayout margin bottom is overridden to 16dp.
    3. Our header with parallax collapseMode is a RelativeLayout with an ImaveView and a View.
    4. This simple View with a BG at the bottom of the top header Relative layout with colour of contrast (here #77000000), acts as the BG for CollapsingToolbarLayout's collapsed Title in white color.

      
    
            
            
    
                
    
                
                
    
            
    
            
    
        
    

    Images for style 1:

    a) When CollapsingToolbarLayout Title is Expanded Fully:

    b) When CollapsingToolbarLayout Title is shrinking upon scroll up:

    2 Answer above

    Method is mentioned already by Joao Ferreira.

    Here is what it looks like with shadowRadius=16: Notice the Shadow

    PS please update or ask more if any confusions :)

提交回复
热议问题