Posted on

Android Layout Building Tricks


android layout
Designed by Freepik

Building layouts isn’t hard in Android Studio: you can use design mode or xml with preview. Although it doesn’t give you actual feeling how app looks. This only happens when you have phone in your hands. Let’s look at some tricks that will make your layout building experience fast and easy.

Layout Bounds

First one is displaying layout bounds, they help you understand a lot about your layouts and other app’s as well. That what it looks like

android layout

You can enable it with Developer Options/Show Layout Bounds or on Android N you can put it to fast access in top swipe menu

android layout

I use it almost every time I build layouts. Especially helps to understand how other people build layouts: pink is margin, padding not colored and boundaries itself. Using it it’s easy to copy some app layout completely, although next step will make it even easier.

Overlay

So with layout boundaries displayed you can go back and forward from your app to one that you’re trying to copy/learn from. And on Nougat it’s pretty easy with double tap on square button.

But there’s even better way with Designer Tools app overlaying image with setting its transparency feature . So you can take a screenshot of some app set it as overlay with 20% alpha, go to your app and compare, copy, whatever you want.

Second great feature is displaying grid for better view alignments. What’s well aligned layout?

android layout

As you see Home, people liked, person posted, message all of it aligns to one vertical line. With grids it’s hard to tell if makes a difference, you just make sure you have as many views alighting one vertical line. One rectangle here is 4 dp wide, you can set custom size in that app

And when you aligned as many views possible – turn off the grid and you’ll see the difference, it’s huge. Without those it’s very hard to tell for sure if your views aligned when you have multiple layout files like with list items etc.

 

Those are just few tricks, but they make so much difference when you use them daily. Alright, thanks for reading. Don’t forget to subscribe, follow me on Twitter, Facebook, G+ and share with friends if you think they will benefit from it!

 


  • Abdulrahim Hannure

    nice helped me alot