Android Basics – Using gravity and layout_gravity attributes to align View Elements

If you are using Linear Layout you have two attributes available to help you align the UI elements.

Gravity Attribute

Use gravity attribute to align the View Content – center, left, right etc.

Layout Gravity Attribute

Use layout_gravity to align the View element itself.

In the following Video I show you how to use these attributes

Source Code :

Android Basics – Learn about Linear Layout

In the last post you learnt about Relative Layout which let’s you place UI components relative to one another.

Linear Layout’s help you to place UI elements next to each other either vertically or horizontally.

In the following Video I will explain this in more detail

Source Code :


Android Basics – A closer look at the Relative Layout

In this Article you will Learn about the Relative Layout.

In the last post you saw how Android provides us with three Layout options – Relative, Linear and Grid.

Relative Layout will help you to position the UI components relative to the Parent or other UI elements.

In the following Video you will learn how to use this Layout.

Source Code :

Android Basics – Learn about Relative, Linear and Grid Layouts

In this Post you will learn the basics of using Layouts. Layouts enable you to position the UI elements on the App Screens.

You can refer to the image and the video to understand the concept better.

You can use three types of Layouts

Relative Layout

Use this Layout to position the UI elements relative to each other.

Continue reading “Android Basics – Learn about Relative, Linear and Grid Layouts”

Android Basics – Learn about onPause and onResume methods in Activity Lifecycle

This Article assumes that You are familiar with the Activity Lifecycle. If not please read my last Post.

There are two more methods which come into picture when an Activity becomes partially visible.

These two Lifecycle methods are onPause and onResume. Please refer to the image and to the Video to understand this better.

Android Basics – What is the Activity Lifecycle

Android Activity follows a Lifecycle from its time of creation till it gets destroyed. In this Article you will Learn about the Lifecycle.

As you can see in the attached diagram an Activity starts when its Launched. That’s the time its Constructor is run and object is created.

This is followed by the onCreate method which is responsible for Screen setup.

Continue reading “Android Basics – What is the Activity Lifecycle”

Android Basics – Using Handler and Runnable to Schedule Code

You will Learn about

  • Handler
  • post method
  • postDelayed method
  • Main Thread

Android runs every App in a separate Process for Security and Scalability.

So when you Run your App Android starts a Thread for the same.

A New Thread

Now if you want to run code which needs to run in the background then its recommended to use a separate thread for doing that.

This will not only improve user experience but also prevent delays and crashes.

Continue reading “Android Basics – Using Handler and Runnable to Schedule Code”

Android Basics – Run your App on your Android Phone

Time to run your App on the Mobile Device. I have provided the Steps, Screenshots and a Video to help you with this.

You can refer to the Images and the Video to get your App up and running on your Mobile Phone.

Android Basics – Call an Activity in another App using Implicit Intent

It is possible to call an Activity in another App from your App by using an Implicit Intent.

In the last Article you saw how to use an Explicit intent to call an Activity in
the same App.

A Scenario can be if you want to send a Text Message when the user clicks on a Button in your App.

To achieve this you need to know a few basic concepts:

1. Action

In an Explicit Intent you need to specify the Action – like Email, Message, Call – basically what kind of Intents you want to use.

Continue reading “Android Basics – Call an Activity in another App using Implicit Intent”

Android Basics – What is an Intent and how is it used to call an Activity ?

In Android App you can have multiple Activities. Each Activity performs a certain task. At times it needs to call another Activity.

To do this Intent is used. Which means an intent to do something.

To call a new MessageActivity from the MainActivity – on click of a Button add the following two lines in your MainActivity

Intent intent=new Intent(this, MessageActivity.class);

That’s it !