Jetpack Compose Flashcards

1
Q

What is jetpack compose

A

A modern toolkit for building native UI on Android using declarative syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a composable function

A

A function that describes UI and can be recomposed efficiently when data changes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is state in jetpack compose

A

Data that can change and trigger recomposition of UI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is remember in jetpack compose

A

A function to create state that persists across recompositions within a composable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you handle navigation in jetpack compose

A

Using the navigation component to manage different screens and their transitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is LazyColumn

A

A composable for efficiently displaying large lists of items vertically

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a modifier in jetpack compose

A

A way to change the appearance or behaviour of a composable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What’s the difference between @Composable with @Preview

A

@Composable is used to define a composable function, while @Preview is used to display a preview of a composable in android studio layout editor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are state composables and stateless composables

A

State composables hold state and can be recomposed when the data changes
Stateless composables don’t hold state and are recomposed when their inputs change

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain how to handle user interactions with composables

A

Use modifiers like clickable, onLongClick or gesture detection APIs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you create custom composables

A

Define functions annotated with @Composable that describe the UI and logic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are slot APIs in Jetpack Compose

A

Allow customization of composable layouts by providing content within them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Explain how to achieve theming consistency across your app

A

Use MaterialTheme to provide a theme throughout the app hierarchy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you handle accessibility in Jetpack Compose

A

Use semantic properties like contentDescription and follow accessibility best practices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are animation APIs in jetpack compose

A

Use AnimatedVisibility or transition to animate composable appearances or changes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Explain how to perform data fetching and asynchronous operations in jetpack compose

A

Use LaunchedEffect or rememberCoroutineScope to launch coroutines within composables

17
Q

How do you handle state hoisting in jetpack compose

A

Lift state to a common ancestor composable to avoid unnecessary recompositions

18
Q

What is the difference between Surface and Box composables

A

Surface provides a material design background, while Box is a generic container for other composables

19
Q

Explain how to implement navigation drawers in jetpack compose

A

Use the NavigationDrawer composable and handle navigation actions

20
Q

How do you integrate bottom navigation with jetpack compose

A

Use the BottomNavigation composable and navigat to different destinations based on selections

21
Q

What are Modifier.fillMaxSize and Modifier.wrapContentSize used for

A

FillMaxSize makes a composable fill it’s parents size, while wrapContentSize sizes the composable based on its content

22
Q

Explain how to create custom modifiers in jetpack compose

A

Define functions that return new modifiers by combining existing ones or adding custom logic

23
Q

How do you test composables in jetpack compose

A

Use the composeUiTest library to write unit and integration tests for composables

24
Q

What are LazyColumnFor and LazyRowFor composables used for

A

Efficiently display large lists of items with access to their index

25
Explain how to handle errors and loading states in jetpack compose
Use composables like Box and If to conditionally display loading or error states based on data availability
26
How do you measure and optimize the performance of your jetpack compose UIs
Use tools like Android Studio Profiler and identify bottlenecks in recomposition
27
What are the benefits of using previews in jetpack compose
Allow for quick visual inspection of composable UIs during development
28
Explain the concept of concurrency and lifecycle awareness in jetpack compose
Use coroutines and LaunchedEffect to manage background tasks and ensure composables handle lifecycle events appropriately