Sunday, 5 July 2020

What is Linear Layout in Android ? And how it works ?

In last post we discussed what are layouts in android and saw various names of layouts that android provides. In this post we will see what is Linear Layout and How it works ( or how we can make designs in android using this layout ).

Linear Layout as the name is suggesting us that it aligns the views in linear fashion. This layout aligns its children in either direction such as horizontal or vertical. You can set the direction (horizontal or vertical) of layout by using 
android:orientation attribute. Let us see diagrammatically how linear layout align its children : 



     
                           
view 1


view 2 
                          
         view 3             view 4         

                                       Fig 0.1 Orientation : Horizontal

        


  
               view 1                              
view 2    
              view 3
              view 4


                                       Fig 0.2 Orientation : Vertical

Now let us see some attributes of linear layout : 

    
 * android:orientation (value = horizontal or vertical)
  
   It will arrange the children in either horizontal or vertical direction.

android:gravity  (value = center|top|bottom|left|right) 
 
  It will position the child in center or top or left or right or topleft(top|left) or topright(top|right) etc.

android:weightSum   (value = any positive integer value such as 1 or 2 or 3 ..so on)

      It defines in how many section or division will linear layout be divided. It affects the value of
 android:layout_weight. Following example will explain it how : 

 if linear layout has given weightSum of 3 , it means it should be divided in three sections,
  now if linear layout has three child such as 3 textviews then if their layout_weight is 1 for 
  each then all textviews will be divided into equal sections. 

 if one of the textview's layout_weight is 2 then it will have twice the section then other two textviews.
 It is not compulsory to provide weightSum to the linear layout. But if you provide layout_weight to its children 
 they will work accordingly. 





 



Layouts in Android


Before moving towards "Layouts in android" , let us discuss "what are layouts ?". In our daily life we surf internet and head on to some website. Website contains some texts, images, buttons, icons etc. We see that in all websites they are aligned or arranged in a fashion so that they follow the design rules and also look better to a user. Layouts are basically the arrangement of various "views" or "components" on the screen or display so that everything can be observed and accessed easily. 

In android , we create apps which contains multiple Activities(screens). Each Activity( screen ) acts as a user interface and therefore "views" are aligned on Activity. Now the question is how we can place various views ( text, button, fields, icons ) on the app screen so that everything looks great and we follow the design rules. 

Android provides us various types of Layouts which we can use to align our view items accordingly. 

Let us see what are the names of those layouts and we will discuss them one by one. Following are the layouts that android provides : 

1. Linear Layout 
2. Relative Layout
3. Constraint Layout
4. Coordinator Layout
5. Table Layout

Let us discuss them one by one in our next post. 

Android Versions

We learned about what is Android and who invented it in our last post. Now let us see what are the versions of android from beginning : 

     * Alpha
     * Beta
     * Cupcake
     * Donut
     * Eclairs
     * Froyo
     * Gingerbread
     * Honeycomb
     * Icecream Sandwich
     * Jellybean
     * Kitkat
     * Lollipop
     * Marshmallow
     * Nougat
     * Oreo
     * Pie
     * android 10
     * android 11

Below are the versions of android listed with their version number, API Level and release date : 

Version Name   Version number  API Level  Release Date  
    
 Alpha
 1.0 1 September 23, 2008
 Beta 1.1 2 February 9, 2009
 Cupcake 1.5 3 April 27, 2009
 Donut 1.6 4 September 15, 2009
 Eclairs 2.0-2.1 5-7 October 26, 2009
 Froyo 2.2-2.2.3 8 May 20, 2010
 Gingerbread 2.3-2.3.7 9-10 December 6, 2010
 Honeycomb 3.0-3.2.6 11-13 February 22, 2011
 Icecream Sandwich 4.0-4.0.4 14-15 October 18, 2011
 Jellybean 4.1-4.3.1 16-18 July 9, 2012
 KitKat 4.4-4.4.4 19-20 October 31, 2013
 Lollipop 5.0-5.1.1 21- 22 November 12, 2014
 Marshmallow 6.0-6.0.1 23 October 5, 2015
 Nougat 7.0 24 August 22, 2016
 Nougat 7.1.0-7.1.2 25 October 4, 2016
 Oreo 8.0 26 August 21, 2017
 Oreo 8.1 27 December 5, 2017
 Pie 9.1 28 August 6, 2018
 android 10 10 29 September 3, 2019
 android 11 11(preview)  2020


Saturday, 4 July 2020

What is Android ? How to make android apps ?

Android is an operating System based on Linux Kernel and other open source software designed primarily for touch screen mobile devices.It is platform independent. What it means ? Have you heard about "Java is platform independent". The platform independent means The programming language( like Java) or the operating system ( like Android) can run on any device irrespective of machine type on which they are installed. Java needs only JVM ( Java Virtual machine ) to enable itself to run on any platform. Android app development requires knowledge of any of following combinations such as  : 

1. Java + Xml
2. Kotlin + Xml
3. Dart( using Flutter Sdk) == Cross platform Sdk developed by Google.

Android app is developed with combination of two approaches : a) Presentation Logic b.) Business Logic

* Java and Kotlin are the programming languages that will help us to write Business Logic (the logic that is written to handle and perform events such as "what should happen when user taps on button or scrolls down ?" ). Xml is used to design the screen or we can say it helps us writing the Presentation Logic. 

* Dart is a programming language created by Google which requires no xml to create designs. It can be used to create presentation and business logic at one side of the coin ( in the same file). Dart can be used after installing Flutter( Sdk used to write apps for cross platform such as Android and iOS with a single code base of Dart programming language ) in Android Studio or VSCode.

Who Created Android ? 
 
 Android was started as a project in Palo Alto, California, in October 2003 by Andy Rubin, Rich Miner, Nick Sears, and Chris White. It was not handled by these people only. The group of companies known as OHA ( Open Handset Alliance) handled and maintained Android. In 2005 Google aquired Android and released its first version in 2008. 

Okay this the basic and enough for this post, Let us see what are the versions of Android in our next post.