Android App Development - Front-end

PoliteAspen avatar
PoliteAspen
·
·
Download

Start Quiz

Study Flashcards

Questions and Answers

What is the purpose of the 'ems' unit of measurement in Android?

To set the width of a TextView/EditText to fit a text of n 'M' letters

What is the purpose of the 'android:inputType' attribute in Android?

To set the type of input allowed in the field

What is the purpose of the 'android:padding' attribute in Android?

To set the spaces between the content and the border of a widget element

What is the purpose of the 'android:margin' attribute in Android?

<p>To set the spaces outside of a view</p> Signup and view all the answers

What is the purpose of the 'android:border' attribute in Android?

<p>To add a line that goes around an object</p> Signup and view all the answers

Where can you save a string value in Android to use it later in the app?

<p>In the strings.xml file in the values sub-folder in the res folder</p> Signup and view all the answers

What is the purpose of the 'android:ems' attribute in an EditText?

<p>To set the width of the EditText to fit a text of n 'M' letters</p> Signup and view all the answers

What is the default unit of measurement for the 'android:padding' and 'android:margin' attributes in Android?

<p>dp</p> Signup and view all the answers

What is the purpose of the 'android:contentDescription' attribute in an ImageView?

<p>To add a description to the ImageView for accessibility purposes</p> Signup and view all the answers

What is the purpose of the strings.xml file in Android?

<p>To store string values that can be used throughout the app</p> Signup and view all the answers

Study Notes

XML in Android App Development

  • XML (eXtensible Markup Language) is used for storing and transferring data, similar to HTML
  • XML is case-sensitive, requires each tag to be closed properly, and preserves whitespace
  • XML tags need not be predefined like HTML

XML Layout File

  • Each XML file used to design the Android UI is known as a Layout file
  • Every tag has its Attributes
  • Root View is a root element of an XML Layout file, and all tags corresponding to various components of the UI must be placed between the starting and ending tag of the main root tag
  • Each Layout file contains only one root tag

Common Layouts

  • Relative Layout: displays its child content in positions relative to the parent
  • Linear Layout: aligns its contents into a single direction, vertical or horizontal
  • Frame Layout: a placeholder on a screen that displays only a single view, i.e., a Fragment

Views

  • All Views are placed in a Layout
  • Text, Images, and buttons are all views
  • View Group is an invisible container that holds multiple views together and defines their layout properties

Common View Groups

  • List View: displays a list of scrollable items
  • Grid View: displays items in a 2D scrollable grid
  • Table Layout: groups views into rows and columns

Attributes in a Tag

  • Android:id: gives a component or tag an id for future reference
  • Android:layout_width and Android:layout_height: specify the width and height of a 2D design component
  • Android:text: specifies the text to be shown in a View

XML Tags for Android

  • TextView: displays a formatted text label
  • ImageView: displays an image resource
  • Button: can be clicked to perform an action
  • ImageButton: displays a clickable image
  • EditText: an editable text field for user input
  • ListView: a scrollable list of items containing other views

RelativeLayout

  • Enables specifying how child views are positioned relative to each other
  • Position properties in child elements:
    • Android:layout_alignParentRight= “true”
    • Android:layout_alignParentLeft= “true”
    • Android:layout_alignParentBottom= “true”
    • Android:layout_alignParentTop= “true”
  • More positions for child elements:
    • Android:layout_centerInParent= “true”
    • Android:layout_centerVertical= “true”
    • Android:layout_centerHorizontal= “true”

Giving IDs to Tags

  • Android:id= “@+id/btnStartApp”
  • Use clear and understandable naming conventions for IDs

More Positions for Child Elements using IDs

  • Android:layout_toRightOf= “@+id/btnStartApp”
  • Android:layout_toLeftOf= “@+id/btnStartApp”
  • Android:layout_above= “@+id/btnStartApp”
  • Android:layout_below= “@+id/btnStartApp”

LinearLayout

  • Aligns all children in either vertically or horizontally
  • Properties:
    • Android:orientation = “vertical”
    • Android:gravity = “center”

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Quizzes Like This

Android App Development Basics
10 questions
Android ListView
38 questions

Android ListView

FerventPhiladelphia avatar
FerventPhiladelphia
Android ListView
99 questions
Use Quizgecko on...
Browser
Browser