(A) Layout Resources

Click this link for Layout details

(B) UI Elements

(a) Views & ViewGroup
Views
  • Views are the fundamental building blocks used to create an app’s user interface (UI).
  • Each view represents a visual component that the user can interact with or display information.
  • Views are the fundamental building block/object of the user interface created from the View class.
  • Views are small/large rectangular areas on the screen and are responsible for drawing and event handling in the Android app.
  • View is the base class for widgets, which are used to create interactive UI components, such as buttons and text fields.
  • Views in Android can be arranged and customized using XML layout files or programmatically through Java or Kotlin code.
  • Some common View elements used in Android applications are:-
    • Basic Views:
      • TextView:
        • TextView is a basic UI widget in Android used to display text to the user.
        • It is a read-only text element (users cannot edit its content).
        • We can customize its appearance and behaviour using various XML attributes like textSize, textColor, gravity, padding, etc.
        • It is one of the most fundamental building blocks for displaying static or dynamic text in Android apps.
        • It is a simple text display element.
        • This view displays text on the screen and can be used to show static or dynamically changing text content.
        • It acts as a label.
        • For example –
<TextView
    android:id=“@+id/program1”
    android:layout_width=“wrap_content”
    android:layout_height=“wrap_content”
    android:text=“Hello World!”
    android:textSize=“18sp”
    android:textColor=“#FF5722”
    android:padding=“16dp” />
      • Plain Text
        • In Android Studio, the Plain Text UI element refers to the EditText widget with the input type set to plain text. This allows users to enter and edit a single line or multiple lines of text.
        • Plain Text is an EditText field where users can input regular text (letters, numbers, symbols).
        • It is commonly used for forms, search bars, or any place where user input is required.
        • For example –
<EditText
    android:id=“@+id/program2”
    android:layout_width=“match_parent”
    android:layout_height=“wrap_content”
    android:hint=“Enter your name”
    android:inputType=“text” />
        • We can customize the behavior of the PlainText field by using different input type values depending on the kind of data we want the user to input.
          • For Single-line text (default): android:inputType=”text”
          • For Email: android:inputType=”textEmailAddress”
          • For Password: android:inputType=”textPassword”
          • For Password: android:inputType=”numberPassword”
          • For Phone/Mobile number: android:inputType=”phone”
          • For Numeric Value: android:inputType=”number”
        • It’s essentially a pre-configured EditText for single-line input.
        • This view is almost similar to EditText.
      • EditText:
        • EditText is a user interface (UI) widget in Android that allows users to enter and edit text.
        • It is an editable text box, commonly used for forms, search bars, login screens, and any place where user input is required.
        • For example –
<EditText
    android:id=“@+id/program3”
    android:layout_width=“match_parent”
    android:layout_height=“wrap_content”
    android:hint=“Enter Student Name”
    android:inputType=“text” />
        • It is a user-input text box/field.
        • It’s used for accepting user input such as text, numbers, etc.
        • Password:
          • The Password UI element in Android is an EditText view.
          • It is used to securely accept passwords by masking the input characters.
          • In Android, the Password input field is created using the EditText widget with a specific inputType that masks the characters as they are typed.
          • The EditText widget allows for secure entry of passwords by displaying dots or asterisks instead of the actual characters. This is done by setting the android:inputType attribute to “textPassword” or “numberPassword”.
          • Android provides a convenient way to toggle the visibility of the password. This can be done using the android:passwordToggleEnabled=”True” feature in conjunction with TextInputLayout. It allows users to see the password when they click an eye icon next to the field.
          • To limit the number of characters a user can enter for the password using android:maxLength=”30″.
          • If we want to show error messages when the password is incorrect, we can do so using textInputLayout.setError(“Password must be at least 6 characters long.”);.
          • For example –
        • <EditText
              android:id=“@+id/program4”
              android:layout_width=“match_parent”
              android:layout_height=“wrap_content”
              android:hint=“Enter your password”
              android:inputType=“textPassword” /> 
      • Button:
        • A Button is a basic interactive UI widget in Android that users can tap or click to act (such as submitting a form, opening a new screen, etc.).
        • Button is an essential interactive element in Android apps, used to perform actions when the user clicks or taps it.
        • It is one of the most commonly used elements in Android apps.
        • This view is used to represent a clickable button that triggers an action/event when pressed by the user.
        • For example –
      • <Button
            android:id=“@+id/btnSubmit”
            android:layout_width=“wrap_content”
            android:layout_height=“wrap_content”
            android:text=“Submit” /> 
      • ImageView:
        • ImageView is a UI widget in Android used to display images (such as PNG, JPG, GIF, etc.) in the app.
        • It can show images from resources, assets, or even from the internet (with additional code).
        • It is used to display images or drawables on the screen.
        • For example –
<ImageView
    android:id=“@+id/image1”
    android:layout_width=“wrap_content”
    android:layout_height=“wrap_content”
    android:src=“@drawable/photo1”
    android:contentDescription=“App Logo” />
      • Container Views:
        • ScrollView:
          • It allows scrolling of the contents if they exceed the screen size.
        • ListView:
          • It displays a scrollable list of items.
        • RecyclerView:
          • It is a more advanced and efficient list view that efficiently displays large sets of data by recycling views.
        • ViewPager:
          • It enables the user to swipe left or right to view different content screens.
        • TabLayout:
          • It represents tabs for switching between different views or sections within an app.
        • Navigation Drawer:
          • It is a sliding panel that displays app navigation options.
      • Interactive Views:
        • CheckBox:
          • It is used to represent a box that can be checked or unchecked by the user.
          • This view is used as multi-select or zero-select options at a time.
        • RadioButton:
          • This view is used to present a set of options where only one can be selected at a time.
        • SeekBar:
          • It is used to display a draggable bar allowing the user to select a value from a range.
      • Specialized Views:
        • DatePicker and TimePicker:
          • It allows users to select dates and times.
        • WebView:
          • It displays web content within the app, allowing for the integration of web-based features.
        • Spinner:
          • It represents a dropdown list allowing users to select one item from multiple options.
        • SeekBar:
          • It provides a draggable thumb to select a value from a range, often used for adjusting settings like volume or brightness.
        • ProgressBar:
          • It indicates the progress of an operation or task that is going on or completed.
    ViewGroup
      • The ViewGroup is a subclass of View and provides an invisible container that holds other Views or other ViewGroups and defines their layout properties.
    (b) Intent
    Click this link for Intents details
    (c) Toast
    Click this link for Toast details

    Loading

    Categories: Android

    0 Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.