Android Material Design Create Efficient and Reusable Layouts

Advanced Gridlayout – Android Development

In this tutorial I will information you thru methods to create a format that appears just like the GOAT app and exhibit the easiest way to create it.

That is the Goat app display that we’ll start to duplicate.

Getting the Icons

For this app we’ll want quite a couple of icons to obtain. Obtain from google icons

ic_add_circle_outline_black_24dp

ic_directions_run_white_36dp

ic_explore_white_36dp

ic_local_offer_white_36dp

ic_more_horiz_white_36dp

ic_remove_circle_outline_black_24dp

ic_search_white_36dp

ic_trending_down_black_24dp

ic_trending_up_white_36dp

Creating the top menu border

girdlayoutOne of the best format for this it to use LinearLayout and use weights to evenly unfold out the icons.

Here we now have added a weight of one for every view. And added some padding to the top and backside of the format.

Creating the bottom border menu

gridlayout

Creating this border requires 3 steps.

Creating the border

Creating a new shape drawable and enter the following. This can create a rectangle shape with strong black shade, white border.

Creating the actual button

We’ll use the shape to create the identical effect for our button by assigning it the background.

Creating the format

Now that we have now created the first 2 steps we will deliver all of them together to create the ultimate format for the underside format menu bar.

For this we’re going to use the FrameLayout which is perfect for this as we will place the views on the left, middle, and right.

Create the primary row utilizing the Gridlayout

It will consist of some steps to lastly complete this step. With the gridlayout you add your individuals views to every grid. Here is how we’ll divide up the grids.

gridlayout

As you’ll be able to see with the strains that make up the gridlayout. All the views might be aligned very simply. But first we’ve to do a couple of things.

Create the Supply button

We  will do this the same means we created the orders button. But this one gained’t have any white border.

Create a brand new drawable and add the next

Download a picture of a sneaker

Obtain an image of a sneaker for use for instance. Or you should use the one in my github.

Creating the final sale format

We additionally have to create one other linearlayout to to add to the gridlayout referred to as the last_sale_row.xml format. The rationale we have to do this is that the icon and the textview have to occupier the same grid.

Creating the precise Gridlayout

You possibly can learn more concerning the gridlayout right here. As there are some options of the gridlayout that was added in API 21. So we need to add the help gridlayout for backwards compatibility to our construct.gradle file.

Now we’re going to fill in the gridlayout now that we now have all the bits collectively. Create a new android.help.v7.widget.Gridlayout referred to as. Create a brand new offers_row and add the following to complete the gridlayout.