Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Android Studio Tutorial: Part-2 (Layouts)

Android Studio Tutorial: Part-2 (Layouts)
Hey friends, 

☺☻☺☻☺

Welcome back to the blog, previously we learned about installing Android Studio and setting up the environment. Now we will learn about using Android Studio. If you have worked on some IDEs like Netbeans android studio will be like a child's play for you, but if you have never worked on any IDE before then don't worry, this post is for you. So let's start it without wasting much time.

Before starting anything lets have a look at the video, it has a very simple example of using linear and relative layout.


                                                                 Subscribe the Channel

In this video, we worked on layouts but, what are they?

In Simple Words, we can say that a layout defines the position of widgets in the UI of the app, it defines the structure of UI.  This is the simplest way to define a layout.

Here, we will talk about six different types of layouts, which are as follows:-


  • Linear Layout
  • Relative Layout 
  • Table Layout
  • Grid Layout
  • Frame Layout
  • Absolute Layout

In this post, we will only discuss the first two layouts, namely Relative Layout and Linear Layout.

Linear Layout 

In this layout, widgets or children can be arranged either vertically or horizontally i.e only in a single direction. This vertical or horizontal arrangement is applied to the layout using the attribute, 'orientation'.  

Attributes for Linear Layout are as follows:-

  • android: baselineAligned:- when true, layout aligns it's children's baseline.                                                                                                                                                           
  • android:baselineAlignedChildIndex:-When a linear layout is part of another layout that is    baseline aligned, it can specify which of its children to baseline align to.                                                 
  • android:divider:- Drawable to use as a vertical divider between buttons.                                                
  • android:weightSum:-Defines the maximum weight sum.
  • android:orientation:-Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column.                                                                                                                                                               
  • android:gravity:-Specifies how an object should position its content, on both the X and Y axes, within its own bounds.                                                                                                                                                                     
  • android:measureWithLargestChild:-When set to true, all children with a weight will be considered as having the minimum size of the largest child. 

    Relative Layout 

    In relative layout, the position of a  child is specified with respect to the layout or other children, the default location of the children is the top left corner, so the positions must be specified in order to rearrange them.

    Attributes for Relative Layout are as follows:-


    • android:layout_below:- Positions the top edge of this view below the view specified with a resource ID.                                                                                                                                               
    • android:layout_toLeftOf:- Positions the left edge of the view to the left of the view specified with a resource ID.                                                                                                                                                  
    • android:layout_toRightOf:- Positions the left edge of the view to the right of the view specified with a resource ID.

    There are other properties too, which you will understand when you will try yourself. That's all for today. I hope you like it, stay tuned for a new post tomorrow.

    If you have any doubts, please like our facebook page and join the WhatsApp group to discuss the doubts by clicking here.
          



    This post first appeared on Code The Tech, please read the originial post: here

    Share the post

    Android Studio Tutorial: Part-2 (Layouts)

    ×

    Subscribe to Code The Tech

    Get updates delivered right to your inbox!

    Thank you for your subscription

    ×