User Interface (UI):
-
Explain the difference between wrap_content, match_parent, and fill_parent in Android layouts.
- wrap_content makes a view’s size just big enough to enclose its content, match_parent (or fill_parent) makes a view fill its parent’s size, taking available space.
-
What is a View in Android?
- A View is a fundamental UI element that can be drawn on the screen, such as buttons, text fields, or images.
-
What’s the purpose of a ViewGroup in Android?
- A ViewGroup is a container for holding multiple child views, helping to organize the layout of an Android user interface.
-
Explain the importance of the dp unit in Android layouts.
- dp (density-independent pixels) is a unit that ensures consistent sizing across different screen densities. It helps create responsive layouts.
-
What is the difference between ListView and RecyclerView?
- Both are used for displaying a list of items. RecyclerView is more efficient and flexible, especially for large datasets, due to its use of a view holder pattern.
-
What is the purpose of the ViewHolder pattern in Android?
- The ViewHolder pattern is used in conjunction with ListView or RecyclerView to improve performance by recycling views and minimizing calls to findViewById().
-
How can you create a custom view in Android?
- To create a custom view, you need to extend the View class or one of its subclasses and override the onDraw() method to define your custom drawing.
-
What is a Toast in Android, and how is it used?
- A Toast is a small pop-up message that appears on the screen for a short duration, providing simple feedback or notifications to the user.
-
Explain the use of the ConstraintLayout in Android.
- ConstraintLayout is a flexible layout that allows you to create complex, responsive UIs with a flat view hierarchy. It’s especially useful for designing responsive and dynamic layouts.