Q-1: Attempt the following (5 Marks)
Questions
a) List features of Android Operating System.
b) Define Android Virtual Devices (AVD).
c) List all attributes to develop a simple button.
d) List any four Android Layouts.
Answers
a) Features of Android Operating System
- Open Source: Android is based on Linux kernel and is open source
- Multi-tasking: Supports running multiple applications simultaneously
- Rich UI: Provides attractive and intuitive user interface
- Connectivity: Built-in support for WiFi, Bluetooth, 3G, 4G, 5G
- Storage: Uses SQLite database for data storage
- Media Support: Supports various audio, video, and image formats
- Messaging: SMS, MMS, and various messaging applications
- Web Browser: Built-in web browser based on WebKit engine
- Java Support: Applications are developed using Java programming language
- Security: Application sandbox for security
- Memory Management: Automatic memory management and garbage collection
- Multi-touch: Support for multi-touch screens
b) Android Virtual Devices (AVD)
Definition: Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.
Key Points:
- Purpose: Used for testing Android applications without physical device
- Configuration: Includes system image, hardware profile, and emulator options
- Components:
- Hardware profile (screen size, resolution, RAM, etc.)
- System image (Android version, API level)
- Storage options (SD card, internal storage)
- Creation: Created using AVD Manager in Android Studio
- Benefits:
- Test on different screen sizes and resolutions
- Test different Android versions
- Debug applications easily
- No need for physical devices during development
c) Attributes to develop a simple button
Common Button Attributes:
- android:id - Unique identifier for the button
- android:layout_width - Width of the button (wrap_content, match_parent, specific dp)
- android:layout_height - Height of the button
- android:text - Text displayed on the button
- android:textSize - Size of the text
- android:textColor - Color of the text
- android:background - Background color or drawable
- android:onClick - Method to call when button is clicked
- android:padding - Internal spacing
- android:margin - External spacing
- android:gravity - Text alignment within button
- android:enabled - Whether button is clickable
- android:visibility - Visibility of button (visible, invisible, gone)
- android:drawableLeft/Right/Top/Bottom - Add icons to button
Example:
<Button
android:id="@+id/myButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me"
android:textSize="16sp"
android:textColor="#FFFFFF"
android:background="#2196F3"
android:onClick="buttonClick" />
d) Four Android Layouts
-
LinearLayout
- Arranges views in a single row or column
- Uses orientation attribute (horizontal/vertical)
- Simple and commonly used layout
-
RelativeLayout
- Positions views relative to each other or parent
- Flexible positioning using relative attributes
- Good for complex layouts with fewer nested views
-
ConstraintLayout
- Most flexible layout manager
- Uses constraints to position views
- Flat view hierarchy for better performance
- Recommended for complex UIs
-
FrameLayout
- Simple layout holding single child view
- Child views are drawn in stack (last added on top)
- Used for fragments and simple containers
Other Common Layouts:
- TableLayout: Arranges views in rows and columns
- GridLayout: Arranges views in grid format
- CoordinatorLayout: Advanced layout for material design
- ScrollView: Provides scrolling functionality