Jul.11

Interview: Android – View

Question: What is Fragment?

Fragment represents behavior or portion of user interface in an activity. Fragment must always be hosted in an activity and the fragment’s lifecycle is directly affected by the host activity’s lifecycle. We can combine multiple fragments in a single activity and reuse a fragment in multiple activities.


Question: What are LinearLayout, RelativeLayout and ConstraintLayout?

LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. We can specify the layout direction with the android:orientation attribute.

RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements or in positions relative to the parent.

ConstraintLayout is use to define a layout by assigning constraints for every child view relative to other views. ConstraintLayout is similar to RelativeLayout, but with more power.


Question: What are view Re-usability and Optimization?

RecyclerView is a more advanced and flexible version of ListView. It is a ViewGroup which renders any adapter-based view. It uses recycle or reusable technology for rendering.

We should use custom styles derived from native styles, instead of using native styles directly.

Also we can use <include> tag in layouts to import other layouts. We should avoid creating same layout again and again.


Question: What is Material Design?

Material design is a comprehensive guide for visual, motion, and interaction design across platforms and devices. To use material design in Android apps, we should follow the guidelines defined in the material design specification and use the new components and styles available in the material design support library.

Android,View,Interview