SlideShare a Scribd company logo
1 of 14
Create New Layout
ANDROID MOBILE APPLICATION
TRAINING VIDEO - 2
Copyright © 2020 Transpose Solutions. All Rights Reserved.
OVERVIEW
In this tutorial, we will learn how to open
an exisiting android project and make
changes to the exisiting layout and add new
widgets.
Copyright © 2020 Transpose Solutions. All Rights Reserved.
WHAT IS A LAYOUT
Android app user interface (UI) is that, user can see and interact with. Android app is built as a hierarchy of
layouts and widgets.
The layouts are ViewGroup objects, containers that control how their child views are positioned on the screen.
Widgets are View objects, UI components such as buttons and text boxes.
Android Studio default setting for the Main Activity (app > res > layout > activity_main.xml) is Constraint
Layout. If required, you can change the layout which is more suitable to your project requirement. Following are
the types of layout available to build a responsive user interface:
Constraint Layout
Linear Layout
Relative Layout
Frame Layout
Note: For more technical documents about User interface and Navigation can be accessed from Google
developer guide: https://developer.android.com/guide/topics/ui
Copyright © 2020 Transpose Solutions. All Rights Reserved.
OPEN AN EXISTING PROJECT
From your task bar/start menu, click open “Android
Studio”
In the Welcome to Android Studio window:
 Click Open an existing Android Studio project.
In the Open File or Project window:
 Go to Android Studio Projects Folder and Select My Mobile App – the project
we created in our earlier tutorial – “build your first app” and click OK.
Note: If you have not viewed our earlier tutorial – build your first app, please
view that before starting this tutorial.
Copyright © 2020 Transpose Solutions. All Rights Reserved.
OPEN - LAYOUT EDITOR
Android studio main window appears after some processes. Please follow the
following steps to get into the layout editor mode:
How to open the layout editor:
In the Project window, open app > res > layout > activity_main.xml.
If your editor shows the XML source, click the Design tab.
Click Select Design Surface and select Blueprint.
Click Show in the Layout Editor toolbar and make sure that Show All Constraints is checked.
Make sure Autoconnect is off. A tooltip in the toolbar displays Enable Autoconnection to Parent when
Autoconnect is off.
Click Default Margins in the toolbar and select your margin to “8”. If needed, you can adjust the margins for
each view later.
Click Device for Preview in the toolbar and select 5.5, 1440 × 2560, 560 dpi (Pixel XL)..
Note: This training material uses Android Studio v3.6.1.
Copyright © 2020 Transpose Solutions. All Rights Reserved.
ADD WIDGETS
Let us remove the exisiting TextView in the layout and add a new EditText control:
Select the TextView and then press delete.
In the Palette panel, select Plain Text Widget and drag and drop it near the top of
the layout. This is an EditText control that accepts plain text input.
Click and hold the anchor on the top side, drag it up until it snaps to the top of the
layout, and then release it. That's a constraint: it constrains the view within the default
margin that was set. In the case, we set it to 8 dp from the top of the layout.
Use the same process to create a constraint from the left side of the view to the left
side of the layout.
Copyright © 2020 Transpose Solutions. All Rights Reserved.
ADD A BUTTON
Let us add a Button next to the Edit Text control we just added in the layout:
From Palette panel, click Button Widget and drag the Button into the design editor
and drop it near the right side.
Create a constraint from the left side of the button to the right side of the text box.
To constrain the views in a horizontal alignment, create a constraint between the text
baselines. To do so, right-click the button and then select Show Baseline ab. The
baseline anchor appears inside the button. Click and hold this anchor, and then drag it
to the baseline anchor that appears in the adjacent text box.
Copyright © 2020 Transpose Solutions. All Rights Reserved.
UI STRINGS
A string resource provides text strings for your android mobile application with optional
text styling and formatting.
There are three types of resources that can provide your app with strings:
String: XML resource that provides a single string.
String Array: XML resource that provides an array of strings.
Quantity Strings (Plurals): XML resource that carries different strings for
pluralization.
Note: For more technical documents about String resources can be accessed from
Google developer guide: https://developer.android.com/guide/topics/resources/string-
resource
Copyright © 2020 Transpose Solutions. All Rights Reserved.
ADD NEW STRINGS
Let us add a new UI strings to our project, so that we can use those new strings to replace
the default values set in the Button and Edit Text control we just added in the layout. To
add new UI strings:
Open the Project window and then open app > res > values > strings.xml.
Click Open editor at the top of the window.
Click Add Key + to create a new string
Steps to add new string key: user_Input
Enter “user_input" in the Key field.
Enter "Enter your name" in the Default Value field.
Click OK.
Steps to add new string key: user_submit
Enter “user_submit" in the Key field.
Enter “Submit" in the Default Value field.
Click OK.
Copyright © 2020 Transpose Solutions. All Rights Reserved.
ASSIGN NEW STRINGS
Let us replace the default values set in the Button and Edit Text control in
the layout with one we just created:
Click the activity_main.xml in the tab bar
Click the EditText control in the layout.
Click “Attributes” on the right sidebar
Locate the text property, which is currently set to “Name”, and delete the value
Locate the hint property and then click pick a resource select “user_input” from
the list.
Click the button control in the layout.
Click “Attributes” on the right sidebar
Locate the text property, which is currently set to “button”.
Then click pick a resource select “user_submit”.
Copyright © 2020 Transpose Solutions. All Rights Reserved.
RESPONSIVE UI
Let us create a layout that’s responsive to different screen sizes, for that
we need to make the EditText control stretch to fill all the horizontal space
that remains after the button and margins are accounted for.
Before you continue, click Select Design Surface in the toolbar and select
Blueprint.
Select both EditText control and Button Control:
Click the EditText control in the layout, then click the Button control, then right-
click select Chains>Create Horizontal Chain.
Select the Button Control and open Attributes. Then set the right margin to 8
dp.
Click the EditText control to view its attributes. Then, click the width indicator
twice so it's set to Match Constraints
Copyright © 2020 Transpose Solutions. All Rights Reserved.
ADD STYLES AND THEMES
Styles and themes on Android allow you to separate the details of your
app design from the UI structure and behavior, similar to stylesheets in
web design.
Styles and themes are declared in a style resource file in res/values/,
usually named styles.xml.
A theme are declared with the android:theme attribute on either the
<application> tag or an <activity> tag in the AndroidManifest.xml file.
We can make changes to the Widgets look and feel by applying changes
to XML attributes values.
Note: For more technical documents about styles and themes can be accessed from Google
developer guide: https://developer.android.com/guide/topics/ui/look-and-feel/themes
Copyright © 2020 Transpose Solutions. All Rights Reserved.
RUN YOUR APP
Use Android studio emulator to run your app:
In the toolbar, select your app from the run/debug configurations drop-down
menu.
 From the target device drop-down menu, select the AVD that you want to run
your app on.
 Click Run
Android Studio installs the app on the AVD and starts the
emulator.
Copyright © 2020 Transpose Solutions. All Rights Reserved.
Thank you for watching the video!
Try our next training video - 3 to learn
- how to create new activity and send
user input from one activity to
another.
Copyright © 2020 Transpose Solutions. All Rights Reserved.

More Related Content

What's hot

Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User InterfaceMarko Gargenta
 
Create yourfirstandroidapppdf
Create yourfirstandroidapppdfCreate yourfirstandroidapppdf
Create yourfirstandroidapppdfmurad3003
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAhsanul Karim
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outletsveeracynixit
 
android layouts
android layoutsandroid layouts
android layoutsDeepa Rani
 
Write an application that draws basic graphical primitives.pptx
Write an application that draws basic graphical primitives.pptxWrite an application that draws basic graphical primitives.pptx
Write an application that draws basic graphical primitives.pptxvishal choudhary
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callmaamir farooq
 
Android Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptxAndroid Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptxvishal choudhary
 
Chapter 07
Chapter 07Chapter 07
Chapter 07llmeade
 
I phone first app ducat
I phone first app ducatI phone first app ducat
I phone first app ducatPragati Singh
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layoutKrazy Koder
 
MDC - Material Design Components & Theming
MDC - Material Design Components & ThemingMDC - Material Design Components & Theming
MDC - Material Design Components & Themingharintrivedi
 
Chapter 2 — Program and Graphical User Interface Design
Chapter 2 — Program and Graphical User Interface DesignChapter 2 — Program and Graphical User Interface Design
Chapter 2 — Program and Graphical User Interface Designfrancopw
 
View groups containers
View groups containersView groups containers
View groups containersMani Selvaraj
 

What's hot (19)

Android Layout.pptx
Android Layout.pptxAndroid Layout.pptx
Android Layout.pptx
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
 
Create yourfirstandroidapppdf
Create yourfirstandroidapppdfCreate yourfirstandroidapppdf
Create yourfirstandroidapppdf
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 
android layouts
android layoutsandroid layouts
android layouts
 
Write an application that draws basic graphical primitives.pptx
Write an application that draws basic graphical primitives.pptxWrite an application that draws basic graphical primitives.pptx
Write an application that draws basic graphical primitives.pptx
 
Android Widget
Android WidgetAndroid Widget
Android Widget
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone call
 
Android Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptxAndroid Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptx
 
Android Intent.pptx
Android Intent.pptxAndroid Intent.pptx
Android Intent.pptx
 
Android development part 2
Android development part 2Android development part 2
Android development part 2
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
 
I phone first app ducat
I phone first app ducatI phone first app ducat
I phone first app ducat
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
 
MDC - Material Design Components & Theming
MDC - Material Design Components & ThemingMDC - Material Design Components & Theming
MDC - Material Design Components & Theming
 
Presentation
PresentationPresentation
Presentation
 
Chapter 2 — Program and Graphical User Interface Design
Chapter 2 — Program and Graphical User Interface DesignChapter 2 — Program and Graphical User Interface Design
Chapter 2 — Program and Graphical User Interface Design
 
View groups containers
View groups containersView groups containers
View groups containers
 

Similar to Create New Android Layout

Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Design for charms & contracts
Design for charms & contractsDesign for charms & contracts
Design for charms & contractsMaria Nasioti
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAhsanul Karim
 
IOS Swift language 1st Tutorial
IOS Swift language 1st TutorialIOS Swift language 1st Tutorial
IOS Swift language 1st TutorialHassan A-j
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1Isham Rashik
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid drawinfo_zybotech
 
Android tutorials7 calculator
Android tutorials7 calculatorAndroid tutorials7 calculator
Android tutorials7 calculatorVlad Kolesnyk
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2Kalluri Vinay Reddy
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outletsveeracynixit
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Ahsanul Karim
 
Visual programming basic.ppt bs cs5th class
Visual programming basic.ppt bs cs5th classVisual programming basic.ppt bs cs5th class
Visual programming basic.ppt bs cs5th classmnewg218
 
App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started GuideVasilis Drimtzias
 
App inventor week4(technovation)
App inventor week4(technovation)App inventor week4(technovation)
App inventor week4(technovation)than sare
 

Similar to Create New Android Layout (20)

Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Design for charms & contracts
Design for charms & contractsDesign for charms & contracts
Design for charms & contracts
 
Android development part 2
Android development part 2Android development part 2
Android development part 2
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
IOS Swift language 1st Tutorial
IOS Swift language 1st TutorialIOS Swift language 1st Tutorial
IOS Swift language 1st Tutorial
 
Android ui with xml
Android ui with xmlAndroid ui with xml
Android ui with xml
 
Visual basic
Visual basicVisual basic
Visual basic
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid draw
 
Android tutorials7 calculator
Android tutorials7 calculatorAndroid tutorials7 calculator
Android tutorials7 calculator
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
Android app development guide for freshers by ace web academy
Android app development guide for freshers  by ace web academyAndroid app development guide for freshers  by ace web academy
Android app development guide for freshers by ace web academy
 
Visual programming basic.ppt bs cs5th class
Visual programming basic.ppt bs cs5th classVisual programming basic.ppt bs cs5th class
Visual programming basic.ppt bs cs5th class
 
App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started Guide
 
Neha
NehaNeha
Neha
 
App inventor week4(technovation)
App inventor week4(technovation)App inventor week4(technovation)
App inventor week4(technovation)
 

Recently uploaded

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 

Recently uploaded (20)

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 

Create New Android Layout

  • 1. Create New Layout ANDROID MOBILE APPLICATION TRAINING VIDEO - 2 Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 2. OVERVIEW In this tutorial, we will learn how to open an exisiting android project and make changes to the exisiting layout and add new widgets. Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 3. WHAT IS A LAYOUT Android app user interface (UI) is that, user can see and interact with. Android app is built as a hierarchy of layouts and widgets. The layouts are ViewGroup objects, containers that control how their child views are positioned on the screen. Widgets are View objects, UI components such as buttons and text boxes. Android Studio default setting for the Main Activity (app > res > layout > activity_main.xml) is Constraint Layout. If required, you can change the layout which is more suitable to your project requirement. Following are the types of layout available to build a responsive user interface: Constraint Layout Linear Layout Relative Layout Frame Layout Note: For more technical documents about User interface and Navigation can be accessed from Google developer guide: https://developer.android.com/guide/topics/ui Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 4. OPEN AN EXISTING PROJECT From your task bar/start menu, click open “Android Studio” In the Welcome to Android Studio window:  Click Open an existing Android Studio project. In the Open File or Project window:  Go to Android Studio Projects Folder and Select My Mobile App – the project we created in our earlier tutorial – “build your first app” and click OK. Note: If you have not viewed our earlier tutorial – build your first app, please view that before starting this tutorial. Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 5. OPEN - LAYOUT EDITOR Android studio main window appears after some processes. Please follow the following steps to get into the layout editor mode: How to open the layout editor: In the Project window, open app > res > layout > activity_main.xml. If your editor shows the XML source, click the Design tab. Click Select Design Surface and select Blueprint. Click Show in the Layout Editor toolbar and make sure that Show All Constraints is checked. Make sure Autoconnect is off. A tooltip in the toolbar displays Enable Autoconnection to Parent when Autoconnect is off. Click Default Margins in the toolbar and select your margin to “8”. If needed, you can adjust the margins for each view later. Click Device for Preview in the toolbar and select 5.5, 1440 × 2560, 560 dpi (Pixel XL).. Note: This training material uses Android Studio v3.6.1. Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 6. ADD WIDGETS Let us remove the exisiting TextView in the layout and add a new EditText control: Select the TextView and then press delete. In the Palette panel, select Plain Text Widget and drag and drop it near the top of the layout. This is an EditText control that accepts plain text input. Click and hold the anchor on the top side, drag it up until it snaps to the top of the layout, and then release it. That's a constraint: it constrains the view within the default margin that was set. In the case, we set it to 8 dp from the top of the layout. Use the same process to create a constraint from the left side of the view to the left side of the layout. Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 7. ADD A BUTTON Let us add a Button next to the Edit Text control we just added in the layout: From Palette panel, click Button Widget and drag the Button into the design editor and drop it near the right side. Create a constraint from the left side of the button to the right side of the text box. To constrain the views in a horizontal alignment, create a constraint between the text baselines. To do so, right-click the button and then select Show Baseline ab. The baseline anchor appears inside the button. Click and hold this anchor, and then drag it to the baseline anchor that appears in the adjacent text box. Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 8. UI STRINGS A string resource provides text strings for your android mobile application with optional text styling and formatting. There are three types of resources that can provide your app with strings: String: XML resource that provides a single string. String Array: XML resource that provides an array of strings. Quantity Strings (Plurals): XML resource that carries different strings for pluralization. Note: For more technical documents about String resources can be accessed from Google developer guide: https://developer.android.com/guide/topics/resources/string- resource Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 9. ADD NEW STRINGS Let us add a new UI strings to our project, so that we can use those new strings to replace the default values set in the Button and Edit Text control we just added in the layout. To add new UI strings: Open the Project window and then open app > res > values > strings.xml. Click Open editor at the top of the window. Click Add Key + to create a new string Steps to add new string key: user_Input Enter “user_input" in the Key field. Enter "Enter your name" in the Default Value field. Click OK. Steps to add new string key: user_submit Enter “user_submit" in the Key field. Enter “Submit" in the Default Value field. Click OK. Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 10. ASSIGN NEW STRINGS Let us replace the default values set in the Button and Edit Text control in the layout with one we just created: Click the activity_main.xml in the tab bar Click the EditText control in the layout. Click “Attributes” on the right sidebar Locate the text property, which is currently set to “Name”, and delete the value Locate the hint property and then click pick a resource select “user_input” from the list. Click the button control in the layout. Click “Attributes” on the right sidebar Locate the text property, which is currently set to “button”. Then click pick a resource select “user_submit”. Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 11. RESPONSIVE UI Let us create a layout that’s responsive to different screen sizes, for that we need to make the EditText control stretch to fill all the horizontal space that remains after the button and margins are accounted for. Before you continue, click Select Design Surface in the toolbar and select Blueprint. Select both EditText control and Button Control: Click the EditText control in the layout, then click the Button control, then right- click select Chains>Create Horizontal Chain. Select the Button Control and open Attributes. Then set the right margin to 8 dp. Click the EditText control to view its attributes. Then, click the width indicator twice so it's set to Match Constraints Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 12. ADD STYLES AND THEMES Styles and themes on Android allow you to separate the details of your app design from the UI structure and behavior, similar to stylesheets in web design. Styles and themes are declared in a style resource file in res/values/, usually named styles.xml. A theme are declared with the android:theme attribute on either the <application> tag or an <activity> tag in the AndroidManifest.xml file. We can make changes to the Widgets look and feel by applying changes to XML attributes values. Note: For more technical documents about styles and themes can be accessed from Google developer guide: https://developer.android.com/guide/topics/ui/look-and-feel/themes Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 13. RUN YOUR APP Use Android studio emulator to run your app: In the toolbar, select your app from the run/debug configurations drop-down menu.  From the target device drop-down menu, select the AVD that you want to run your app on.  Click Run Android Studio installs the app on the AVD and starts the emulator. Copyright © 2020 Transpose Solutions. All Rights Reserved.
  • 14. Thank you for watching the video! Try our next training video - 3 to learn - how to create new activity and send user input from one activity to another. Copyright © 2020 Transpose Solutions. All Rights Reserved.