COURSE 5: Create the User Interface in Android Studio QUIZ ANSWERS

Week 1: Basic UI creation in Android

Meta Android Developer Professional Certificate

Complete Coursera Answers & Study Guide

Enroll in Coursera Meta Android Developer Professional Certification

Basic UI creation in Android INTRODUCTION

Introduce different approaches for building UI with Kotlin and build a basic UI with the Interface Builder.

Learning Objectives

  • List and compare the different options for building UI programmed by Kotlin
  • Build a simple UI using traditional View system and the Layout Editor
  • Build a simple UI using composable functions in Jetpack Compose
  • Review the different parts of the app development process.

KNOWLEDGE CHECK: ACTIVITIES AND VIEWS

1. The first screen that appears after an app is launched is known as a _____________?   

  • Screen class
  • Main Activity (CORRECT)
  • Component Activity

That’s correct! By default the Main Activity is the first screen that appears after an app is launched.    

2. What are the advantages of using Jetpack Compose for UI development? Check all that apply.    

  • It helps developers maintain a consistent UI across multiple devices and platforms such as Android, iOS and the web. (CORRECT)
  • It builds a UI without needing to use an Activity.
  • It simplifies the development of UI components for Android applications (CORRECT)
  • It can help build a UI using less code (CORRECT)

That’s correct! This is a feature of Jetpack Compose.    

That’s correct! This is a feature of Jetpack Compose.    

That’s correct! This is a feature of Jetpack Compose.    

3. What is the purpose of View Groups when building an Android UI? Select all that apply.    

  • To allow for the creation of complex user interfaces (CORRECT)
  • To replace the use of TextView     
  • To provide a better organization of views. (CORRECT)
  • To define the navigation paths between screens    (CORRECT)

That’s correct!  Along with Views and Layouts, View Groups aid the building of a more complex UI.      

That’s correct! Using View, groups the structure of the user interface.    

That’s correct! View Groups aid the connection of multiple UI screens. 

4. Which of these are commonly used views in Android applications? Select all that apply.    

  • TextView (CORRECT)
  • TextField (CORRECT)
  • ActivityView
  • ImageView (CORRECT)
  • Button (CORRECT)
  • ButtonView

That’s correct. TextView is used to display text.    

That’s correct. A text field allows user input.    

That’s correct. ImageView displays images.    

That’s correct. A button allows user input. 

5. Which of the following are layout views that can be used in Android UI design. Select all that apply.    

  • GridLayout (CORRECT)
  • LinearLayout (CORRECT)
  • UILayout
  • ViewLayout
  • RelativeLayout (CORRECT)

That’s correct! A GridLayout is segmented with invisible lines to form cells in a grid of rows and columns.     

That’s correct! A Linear Layout linearly organizes the contained views horizontally or vertically.    

That’s correct. A Relative Layout specifies the position of contained views relative to each other.  

6. This course provides you with an introduction to building the UI in Android Studio. 

  • True (CORRECT)
  • False

Yes. This course covers materials that will aid you in creating beautiful and functional user interfaces in Android.

7. When building a mobile user interface, some design considerations and principles to consider include. Select all that apply.

  • Users should feel that they are in charge of the interface and interactions. (CORRECT)
  • When users make a mistake, they should be able to reverse their actions easily. (CORRECT)
  • The UI should present easy access to relevant actions and display all possible navigational elements and links to all actions, including all information it can gather so users will have everything at their fingertips.    
  • The UI should be responsive and seamlessly adapt to different devices. (CORRECT)
  • The UI should provide feedback for the actions users take. (CORRECT)

That’s right. Putting users in charge of the interface will make them feel at ease. They will learn quickly and get a sense of achievement.

That’s right. The user should always be able to reverse their actions quickly. This allows users to explore the product without fear of failure.

Correct. A UI should be flexible and adaptive, reorganizing the layout of the various UI elements based on the window size available to the app.

Correct. A further  way to boost user confidence is to provide feedback as they navigate and interact with the interface.

8. When you are ready to create your own project in Android Studio, you will use an emulator, which allows you to simulate your app in Android Studio without needing to install the application on an actual physical device.

  • True (CORRECT)
  • False

That’s correct. An emulator conveniently allows you to simulate your app in Android Studio without needing to install the application on an actual physical device.

9. Elements like buttons, labels, text fields and images combined are the same as activity in Android.

  • True
  • False (CORRECT)

That’s right. An activity is the app component that contains the user interface and represents the app screen. You normally find several elements on the screen, such as different kinds of buttons, labels, text fields, images, and so on. All of these make up the app’s user interface.

10. Android application’s package name is not used to uniquely identify the app in the Google PlayStore.

  • True
  • False (CORRECT)

That’s right. The package name uniquely identifies the app in the Google PlayStore.

11. When a new project is created in Android Studio, it generates an Acitivity_Main.XML file which is editable.

  • True (CORRECT)
  • False

That’s right. The Activity_Main.XML file is automatically generated by Android Studio. I can edit it in code view and preview its output in design view.

12. If I want to add a TextView in my UI, I must define the string resource and set the text attribute of TextView to that string. 

  • True
  • False (CORRECT)

That’s correct. It is not mandatory to define a string resource for a TextView. You can set the text by defining android:text attribute for the <textview> in XML. By defining string resource, however, we can avoid duplication, and strings are easier to maintain.

13. Which of the following are states in the activity lifecycle? Select all that apply. 

  • Created (CORRECT)
  • Started (CORRECT)
  • Resumed (CORRECT)
  • Paused (CORRECT)
  • Stopped (CORRECT)
  • Destroyed (CORRECT)

That’s right. This is the state when an activity launches.

That’s right. This is the state when the activity becomes visible on  the screen. 

That’s right. This is the state when the activity gains focus.

That’s right. This is the state when the activity is no longer in the foreground. 

That’s right. This is the state when the activity is no longer visible.  

That’s right. This is the state when the activity is terminated.   

SELF-REVIEW: A BASIC UI WITH COMPOSE

1. When defining the string resource in the exercise, what was the ID of the title string? 

  • R.string.title (CORRECT)
  • R.id.title 
  • R.id.string.title

Correct. The string inner class in R contains the IDs of the string resources

2. Adding the font size parameter to RestaurantName() composable limits it to emit Text of 32sp only.

  • True 
  • False (CORRECT)

Correct. The font size of the RestaurantName() text would vary depending upon the value passed as an argument

3. How many arguments were passed to the RestaurantNamePreview() function?

  • None (CORRECT)
  • Two
  • One 

Correct. The preview function did not accept any argument.

4. In UI development, the imperative approach defines step-by-step how to build the UI while the declarative approach focuses on what to display as opposed to how.

  • True (CORRECT)
  • False

That’s right. The imperative approach to UI development requires that you define step-by-step how to build the UI. The declarative approach, on the other hand, focuses on what rather than how. You give priority to what you have to show, meaning the data.

5. When  defining composable functions, you still need to define the XML code since it is part of the code.

  • True
  • False (CORRECT)

That’s correct. When defining composable functions, there is no need to define any XML since everything will be defined in the Kotlin program.

KNOWLEDGE CHECK: INTRODUCTION TO COMPOSABLE UI

1. Declarative UI programming allows developers to define the UI and its behavior in a concise and expressive way by describing the desired result instead of the details of how to achieve it.    

  • True (CORRECT)
  • False

That’s correct.  This describes the concept behind Jetpack Compose’s declarative UI programming model.

2. In Jetpack Compose the ‘Compose’ item can best be described as:    

  • A reusable view component. (CORRECT)
  • A library for developing UI that is part of the Jetpack suite.
  • Compose is a tool that builds a UI without needing to use an Activity (CORRECT)

That’s correct! Compose is an atomic UI element and is part of the Jetpack compose library.

That’s correct! Compose is a library for developing UI and is part of the Jetpack suite.

3. What are the three main benefits to using a declarative approach when building an Android UI? Select all that apply.

  • Easier to read and debug code (CORRECT)
  • Less complex UI components 
  • Reduced need for unit tests 
  • More succinct code (CORRECT)
  • Improved performance (CORRECT)

That’s correct! This can be a benefit of the declarative approach.

That’s correct! This can be a benefit of the declarative approach.

That’s correct! This can be a benefit of the declarative approach.

4. In this code,a composable function is defined. What is the name of this function?

@Composable
fun MainPanel(name: String) {
Text(text = "$name")
}
  • MainPanel (CORRECT)
  • Composable
  • Text

That’s correct!  MainPanel is the name of the function.

5. In this code, a composable function is defined. In the second-last code line the “name” argument is passed to another function Text. What is the best description of this function?

@Composable
fun MainPanel(name: String) {
Text(text = "$name")
}
  • A variable          
  • A built-in composable function in the Compose library. (CORRECT)
  • A function written by the developer.

That’s correct! Text, is a built-in composable function in Compose library and it is responsible for creating the text UI element that appears on the screen.

SELF-REVIEW: DEFINING A LOGIN SCREEN WITH COMPOSE

1. In this exercise, which arguments were used to position content on the screen?              

  • horizontalAlignment = Alignment.CenterHorizontally
    and
  • verticalArrangement = Arrangement.Center (CORRECT)
  • verticalArrangement = Arrangement.Center
  • horizontalAlignment = Alignment.CenterHorizontally

Correct! Both arguments were used to arrange and align composables in the Column.

2. In this exercise, what was the name of the Composable used to add Little Lemon logo?                          

  • Painter
  • Image (CORRECT)
  • Drawable
  • ImageView

Correct! The composable used to display images is called Image. The painterResource was used to set the image source for the little lemon logo drawable.

3. In this exercise, what annotation is required to create Composable Preview?

  • Composable annotation only
  • Preview annotation only 
  • Composable and Preview annotations (CORRECT)

Correct! Both annotations are required. The Composable annotation is used to define composable and the Preview annotation is used to create preview of the Composable.

4. Layouts are UI elements that display on the screen and serve to arrange items horizontally and vertically.

  • True
  • False (CORRECT)

That’s correct. Layouts are UI elements that do not themselves carry a visible UI but act as a container to the UI elements. They are the guides in organizing and arranging other UI elements on the screen.

5. When creating your UI, it is possible to nest composables, meaning that you can have more than columns or rows inside another column or row.  

  • True (CORRECT)
  • False

That’s right. It’s possible to nest composables and can be represented with a tree structure.

Coursera Meta Android Developer Professional Certificate Answers and Study Guide

Liking our content? Then don’t forget to ad us to your bookmarks so you can find us easily!

Weekly Breakdown | Meta Study Guides | Back to Top

MODULE QUIZ: BASIC UI CREATION IN ANDROID

1. The nesting of composables in a UI can best be represented with a tree structure. 

  • True (CORRECT)
  • False

That’s correct! A tree or hierarchy structure can represent the nesting of composables in a UI with the topmost composable in such a structure being called the root of the tree.

2. What is an Activity in Android UI Development? 

  • A special type of ViewGroup container 
  • A technique that allows users to interact with the app UI. (CORRECT)
  • A function that performs a calculation 
  • A resource file used to store application data 

That’s correct. An activity is the app component that contains the user interface and represents the app screen.

3. How does an Activity allow the user to interact with an Android app? 

  • It provides the window for the app’s user interface and allows the user to interact with the UI elements. (CORRECT)
  • It provides the window for the app to access data from the web. 
  • It allows the app to access system resources. 

Correct! It provides the window for the app’s user interface and allows the user to interact with the UI elements. 

4. Which of the following states is NOT part of the Activity Lifecycle in Android UI Development? 

  • Resumed
  • Started
  • Deleted (CORRECT)

That’s correct.  ‘Deleted’ is not an activity lifecycle state.

5. Which of these methods are called as part of the Activity Lifecycle in Android UI Development? Select all that apply. 

  • onStart() (CORRECT)
  • onInitialized()
  • onCreate() (CORRECT)
  • onDestroy() (CORRECT)

That’s correct! onStart() is a method that is part of the Activity Lifecycle.

That’s correct! onCreate() is a method that is part of the Activity Lifecycle.

That’s correct! onDestroy() is a method that is part of the Activity Lifecycle.

6. What is a Composable in Android UI Development? 

  • A reusable component in Jetpack Compose  (CORRECT)
  • An animation used to transition between activities 
  • A library of user interface components

That’s correct. A Composable is a component of Jetpack Compose

7. Which of these is a way to preview the appearance of an Android UI

  • Use the Android Studio Debugger
  • Use the Android Studio Emulator
  • Use the Android Studio Layout Editor (CORRECT)

That’s correct. You can preview in the Android Studio Layout Editor and you can also preview appearance using the @preview annotation.

8. When you are specifying the size of an element on an Android UI, you can use the dp unit of measurement. This term is shorthand for?

  • Dots Per Inch
  • Density-dependent pixel
  • Density-independent pixel (CORRECT)

Density-independent pixel is correct. 1 dp is equivalent to one pixel on a 160 dpi screen.

9. When you are specifying the size of an element on an Android UI, you can use the sp unit of measurement. This term is shorthand for?

  • Scale-dependent pixel
  • Pixel Point
  • Scale-independent pixel. (CORRECT)

Scale-independent pixel is correct. It is similar to dp and often used to specify font sizes.

10. Which of these are valid guidelines for creating efficient layouts? Select all that apply.

  • Avoid using too many Views (CORRECT)
  • Avoid linear layouts
  • Avoid unnecessary nesting (CORRECT)
  • Avoid deep nesting (CORRECT)

That’s correct. This tip will help to create efficient layouts.

That’s correct. This tip will help to create efficient layouts.

That’s correct. This tip will help to create efficient layouts.

Interactive CSS CONCLUSION

To be written

Subscribe to our site

Get new content delivered directly to your inbox.

Liking our content? Then, don’t forget to ad us to your BOOKMARKS so you can find us easily!