Monday, 23 February 2015

Layout's in Android

Layout in simple terms determines how the items are being displayed for the user in an activity in the app or widget. The layout can be fixed either at the design time or at the run time. Following are the few basic layouts in Android

1.       Linear Layout
Linear layout is used to align all its child elements in a specific direction either horizontally or vertically.

2.       Relative Layout
Relative layout is used to align all its child elements based on the position of other element within it. If no relative positioning is given all the elements will be in the same place.

3.       Table Layout
Table layout is used to group the elements as rows and columns. Where each rows has zero or one cells, where each cell can have a view object.

4.       Grid Layout
Grid layout is used to display a 2-dimensional scrollable grid, generally the items to the list are added using a List Adapter.

5.       Frame Layout
Frame layout is generally used to as a placeholder on the screen for displaying an item. It generally blocks out an area in the screen to display the single item.

6.       List View
List layout is used to display a list of items with a scrollable option, generally the items to the list are generally added using an Adapter. The list of items can be a text or custom designed by extending the Base Adapter.


These are the main layout which we will be working on. 

Friday, 30 January 2015

Android application key components

This tutorial explains some of the basic key components of an Android application, which will be helpful in creating an Android project.

Activities: An activity is a single screen in which a user interacts in an android application. An application can have more than one activity. When an application starts it calls the default activity mentioned in AndroidManifest.xml (Refer HelloWorld example in the previous blog) as highlighted below, this can be changed at any point of design time.
<activity
            android:name=".MainActivity"
            android:label="@string/app_name" >

An activity can call / start another activity when required.

Services: Service is the component that is used to perform action in the background for an application without any user interaction. It can used for logging or to perform work for remote process.  

Content Provider: It’s the standard interface to share data between processes and provide mechanism for defining data security. Used to store data in the file system or use SQL Lite. For example using the content provider the app can read and modify the contact details using the Android provided content provider.

Broadcast Services: It’s a way to listen to system wide even happening in your Android device which is accessible to all apps. Some of the Android provided broadcast services are Screen turned on, battery is low, call/SMS is received, phone is booted etc.

Intents: It’s a messaging object you can use to request an action from another component. An Intent is the key component to call one activity from another activity. For example from our app we can request camera app to take a picture.
Explicit Intent: Specify the component to start by name like call another activity in the same app.
Implicit Intent: Does not specify the component to start instead declare a general action to perform which allows a component from another app to handle that.

Fragments: Fragment is the section of the activity which represents the behavior or a portion of user interface in an activity. An activity can have more than one fragment. A fragment has its own life cycle which can be removed or added at any point when an activity is running.

Views: It’s the place where all the UI elements are being placed in the android application.

Layouts: Layout in Android describes how the UI should look in an activity. This can be declared in the UI XML and/or instantiate the layout at runtime. This can be customized as per required. There are various types of layouts like Linear, Relative, List, Grid etc.


Resources: Resource is a component of the Android application which is used to keep track of all the non-code assets of the application. Resources can be a XML file, images, audio files, etc.