Yaron Vazana

NLP, Algorithms, Machine Learning, Data Science, tutorials, tips and more

  • About
  • Blog
  • Projects
  • Medium

Contact Me

yaronv99 [at] gmail.com

Powered by Genesis

You are here: Home / Android / Material Design Collapsing Toolbar With Image

Material Design Collapsing Toolbar With Image

December 28, 2015 by Yaron Leave a Comment

One of the best Material Design’s component is the Collapsing Toolbar. Many android apps use this concept as it brings simplicity, elegance and beauty to the screen. Using images is a great practice in general, mobile screens are much smaller so less images can fit in. Showing an image as the main header and collapsing it when the user scrolls, allows us to show more above the fold content in less space.

Making long story short, this is the final result…

Collapsing toolbar with image open Collapsing toolbar with image close

Elements we Need

The implementation is straight forward, we use the following elements in order to create the full layout:

  • CoordinatorLayout – the top level screen element
  • AppBarLayout – the element to handle the scrollings
  • CollapsingToolbarLayout – this element contains the image and the toolbar to collapse/expand
  • ImageView – a regular image placeholder
  • Toolbar – material design app toolbar
  • NestedScrollView – defines a scrollable area on the screen

Special Properties

We specify the height of the toolbar when it’s open:
android:layout_height=“192dp“

We set the scrolling effect attribute:
app:layout_scrollFlags=“scroll|exitUntilCollapsed“

We set the image animation to be parallax and set the translation multiplier on the transition:
app:layout_collapseMode=“parallax”
app:layout_collapseParallaxMultiplier=“0.7“

We set the toolbar to stay pinned to the top of the screen when the layout is fully collapsed
app:layout_collapseMode=“pin“

All the rest of the page content will go inside this element, this content will be scrollable:
android.support.v4.widget.NestedScrollView

The text automatically shrinks as the CollapsingToolbarLayout is collapsing.

Take a look at the animation here

Subscribe to Blog

Subscribe to get the latest posts to your inbox

Cheers

Filed Under: Android, Mobile Tagged With: Android, Apps, Google, Material Design, Mobile, Programming

I am a data science team lead at Darrow and NLP enthusiastic. My interests range from machine learning modeling to solving challenging data related problems. I believe sharing ideas is where we all become better in what we do. If you’d like to get in touch, feel free to say hello through any of the social platforms. More About Yaron…

SUBSCRIBE TO BLOG

Subscribe to Blog

Subscribe to get the latest posts to your inbox

Recent Posts

  • Training an AutoEncoder to Generate Text Embeddings
  • Using Dockers for your Data Science Dev Environment
  • Identifying Real Estate Opportunities using Machine Learning
  • How to Create a Simple WhatsApp Chatbot in Python using Doc2vec
  • Average Word Vectors – Generate Document / Paragraph / Sentence Embeddings
  • Visualizing Vectors using TensorBoard
  • Training a Doc2Vec Model with Gensim
 

Loading Comments...