Mobile Application Development - Android User Interface Design Essentials
Mobile Application Development - Android User Interface Design Essentials
Presented By
S.Vijayalakshmi B.E,
Assistant Professor,
Department of Computer Science,
Sri Sarada Niketan College for Women, Karur.
User Interface (UI) Elements
• Definition: UI elements are components that allow users to
interact with the app.
• Common UI Elements:
• Buttons: Initiate actions (e.g., submit, cancel).
• TextViews: Display text or information.
• EditTexts: Input fields for user data.
• ImageViews: Display images.
• Checkboxes, RadioButtons: For user selection.
• Spinners: Dropdown selection.
• ProgressBars: Indicate ongoing tasks.
TextView & EditText
TextView:
• Used to display read-only text.
• Can be styled with different fonts, sizes, and colors.
EditText:
• Allows user input.
• Supports different input types (e.g., text, number,
password).
• Common attributes: hint, maxLength, inputType.
Buttons and ImageViews
Button:
• Commonly used for user actions.
• Can be customized with different styles and colors.
• Example: <Button android:id="@+id/myButton"
android:text="Click Me" />
ImageView:
• Used to display images or icons.
• Supports various image formats (e.g., PNG, JPG).
• Example: <ImageView android:id="@+id/myImage"
android:src="@drawable/my_image" />
Layouts in Android
• Definition: Layouts define the structure of the UI by arranging UI
elements in specific ways.
• Types of Layouts:
• LinearLayout: Organizes children either vertically or horizontally.
• RelativeLayout: Allows positioning of UI elements relative to each
other.
• ConstraintLayout: Flexible layout for designing responsive UIs.
• FrameLayout: A simple layout that stacks child views on top of
each other.
• TableLayout: Organizes UI elements in a grid or table-like
structure.
RelativeLayout
Definition: Allows UI elements to be positioned relative to each other or to the
parent container.
Attributes:
• android:layout_alignParentTop="true"
• android:layout_below="@id/anotherView"
• Example Code:
xml
Copy code
<RelativeLayout>
<TextView android:id="@+id/title" android:text="Title" />
<Button android:layout_below="@id/title" android:text="Next" />
</RelativeLayout>
ConstraintLayout
Definition: A flexible and powerful layout that enables you to design
complex UIs by defining constraints between UI elements.
Key Features:
• Can replace LinearLayout and RelativeLayout for more complex
designs.
• Supports drag-and-drop UI design in Android Studio.
Example Code:
xml
<androidx.constraintlayout.widget.ConstraintLayout>
<TextView android:id="@+id/myText" android:text="Hello World!" />
Drawing on the Canvas