It is nice to adjust sometimes.

Commonly when we use view pager, all our views try to fit into a specified dimension. This is fine in most of the scenarios but how about making our screen to adjust with each view in focus on view pager. Something like in the below image:

Content shifted up and down as per the image height

As you can see our action buttons and content below it shift downwards if an image with height greater than the previous image comes in focus and vice versa. So let’s dive straight into the code and get this done.

Step 1: Create a class AdjustingViewPager (obviously you…


Want to wake up early! Sleep early! Workout daily!

Learn cooking! Meditate daily! Complete a course module!

And this and that and etc and etc.. !!!

And Guess what?

Always ended up Sleeping late! Waking up late! No

workout! Only eating! Never meditated! and this and that

and etc and etc..!!

Life has been tough Man!

It’s been a while that I’m trying to figure out why my daily routine is so messed up 🤔. Thanks to my dedicated procrastination and sheer laziness that my daily routine had been so unproductive. Even knowing the consequences of such an unproductive routine…


Communication components

It seems a bit confusing while setting up communication of Bluetooth LE with our apps and guess what — it is! But we’ll be moving ahead to the point and understand what matters in order to make it work in the simplest manner.

Before integrating the BLE communication, we should be clear on few terms:

Generic Attribute Profile (GATT) — The GATT profile is a general specification for sending and receiving short pieces of data known as “attributes” over a BLE link. All current Low Energy application profiles are based on GATT.

Attribute Protocol (ATT) — GATT is built on…


If it is a need, Create it and take charge!

When it comes to create something which is not available on the layout.xml as native component, developers face real challenge. When drawables are not enough and styles are not sufficient, what we left with is the option of Drawing it!

Canvas — the real play ground wherein a developer can create any type of view or animation. But there is a hesitation in opting for it because it seems a bit complicated but actually it is not. So let’s dive into the world of Canvas.

Clock drawn on Canvas

Exactly! We’re going to create…


Remove Redundancy and let the new come in.

In Android Application Development, one thing which a developer get to introduced in the very beginning and then almost every day, is this statement

findViewById(R.id.viewId);

Well, it has a very important role in development because a view should be binded before accessing it in an Activity or Fragment. But, what if you have multiple views for which you keep on writing findViewById statement multiple times? It is irritating and doesn’t looks good. It’s Redundant.

It can’t be completely omitted but can be written in a structured and decent manner. ButterKnife which is…


It is important to be connected.

Mostly in all of our apps, something or the other depends on the Internet. Whether it is API call, syncing data in background or updating UI based on Internet state, we need to be informed as soon as the Internet state changes.

We do this generally in following manner:

  1. By checking the Internet connection state statically at run time.

2. Creating background service and sending data to our activity/fragments for any change detected.

First method has limitation of not being real time. …


System should be distributed to layers and each layer should have unique responsibility.

We all have been using SQLite database in our android applications to store data locally. But creating, managing database and then accessing it all over the application is a bit cumbersome. Handling the proper opening and closing of Cursor and database object is also a trauma.

I escaped from the above hell by creating a Repository layer in the application using Room (architecture component and data persistence by Google) and Dagger 2( dependency injection library maintained by Google).

Here is a detailed view of how it looks…


Finding the simplest way of doing something is the hardest.

We all have been using parallax effect on views for intuitiveness in user interface. I always wondered that do I’ve to use some third party library to achieve this task? Well no more!

Here is the simplest way with which you can create a parallax effect using ScrollView. So let’s get started.

Firstly, we need to have a scroll listener on ScrollView and we can add it one by using the following code on ScrollView object.

scrollView.getViewTreeObserver().addOnScrollChangedListener(ScrollListener);

Secondly, we just need to calculate the translation factor to shift our views upwards/downwards. Below is the complete code you need to achieve this.

From my Github gist
Without scroll

Development is not coding, it is creativity

When it comes to display symbols, icons and static images, we generally use png/jpeg files. These files take memory, increase the apk size and also affect the speed of execution.

In this project we’re using Typeface font files mainly FontAwesome. This is very small sized file which contains symbols and we can use them as text in our layouts directly. Their color and size can be changed
at run time. Their execution is very fast. Hence making our app light and fast.

For how to use the FontAwesome, check this post.

Now, whenever…


The day i saw Font Awesome, i immediately switched to it and using it still. It is exactly what i was looking for to replace my symbols, icons and static images in app to something which is more flexible and easy to use and light weight.

It is Typeface Font File which contains icons which are vector images. Each icon has a unique code and by using the respective code, we can display the icons in our app. These icons can be scaled just like a text in a TextView. Their color can be changed. …

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store