Whether you are looking to build a simple video, a bottom button or a collapsing tab bar, my Android utilities library is your one-stop shop. I created the HELU repository in an effort to make the Android development process smoother.
This week is all about HELU Parallax View. Every once in a while you may receive designs containing parallax images. Implementing the animation yourself can be a tricky task. Don’t worry. HELU Parallax View will get the whole job done for you. It is built at the top of ImageView and can be used anywhere. It doesn’t matter if you put it inside ScrollView, RecyclerView or any layout. All computations are made by the absolute position of HELU Parallax View on the screen.
Let’s try it yourself. Start by adding the library to you gradle file:
Now you are ready to use HELU Parallax View. Let’s assume, for example, that you already have a layout, including ScrollView with a vertical LinearLayout in it. All you need to do is simply add HeluParallaxView into it:
<cz.helu.heluparallaxview.HeluParallaxView android:layout_width="match_parent" android:layout_height="200dp" android:src="@drawable/kitten" />
If you duplicate this view a few times, the result should look like this:
Let’s explore the library a little bit and take a deeper look what we can do with it. There are a few attributes we can set to HELU Parallax View.
The most important attribute for us would probably be the
scale one. This will determine how much “parallax” will be applied to the image. A lower value means that the image won’t “scroll” so much. A larger value, by contrast, will increase the scrolling behavior. The minimum is 1, which means there will be no parallax at all. Here is an example of
Another useful attribute is
app:reverse. This will change the direction in which the parallax is applied. You can change the direction for X, Y or both axis. Here is an example of
You might have a layout that is scrollable both vertically and horizontally at the same time. In that case, you’ll want to check out
app:blockParallaxY. It will let you block parallax in a selected direction.
The last attribute you can set is Interpolation, which is set to linear by default. This can be a little bit funny thing to try. Here’s an example:
Pretty funny, huh? You can also set all those attributes programmatically. Have a question or suggestion? Feel free to contact me. You can see all methods and examples here or go to STRV.io, STRV's new open source library hub.
You might also like...
A Photo Series Inside STRV's Prague Office
In May 2016, we gutted and uprooted our former code & design cave, packed our gadgets and started a new chapter – in a much bigger space. And so we moved in. Smack dab in the coffee-addict-code-punching-some-call-it-hipster region of Pr...
Talent, Inside STRV, Frontend, Community, Conference
How to Get Your Tech Talk on Stage From 0–8 Times in One Year
April 2018. Our Speakers Program was born. Since then, we’ve already held a series of 10 workshops and trainings. 53 devs went on stage while 17 of them spoke in 11 different countries. We code. We speak. We share. And we’re still counting....
Headless CMS — the best solution for content development
As the world becomes more connected, an increasing number of companies are turning to content management systems to better engage with their customer base. We’ve all heard of WordPress, Drupal, Joomla, Sitecore and Squarespace. However, man...