Wednesday, March 20, 2024

Comparision of android native xml UI components and the Getpack UI components

Certainly I want to see side by side how the old android native xml UI components and the Getpack UI components. if you guys are started learning about the getpack compose this article will help you to understand better about the components.

Just go thought the below comparison.

check the LinkedIn


  1. Text

    • Jetpack Compose
    • Text(text = "Hello, world!")
    • Native Android XML
    • <TextView android:text="Hello, world!" />

  2. TextField

    • Jetpack Compose
    • TextField(value = textState, onValueChange = { newText -> textState = newText })
    • Native Android XML
      <EditText android:text="@={viewModel.text}" />


  3. Button

    • Jetpack Compose
    • Button(onClick = { /* Do something */ }) { Text("Click me") }
    • Native Android XML
    • <Button android:text="Click me" android:onClick="onClickHandler" />
  4. Image

    • Jetpack Compose
    • Image(painter = painterResource(R.drawable.my_image), contentDescription = "My Image")
    • Native Android XML
    • <ImageView android:src="@drawable/my_image" android:contentDescription="My Image" />
  5. Row / Column

    • Jetpack Compose
    • Column { /* Add children here */ } or Row { /* Add children here */ }
    • Native Android XML
      <LinearLayout android:orientation="vertical|horizontal">
  6. Spacer

    • Jetpack Compose
    • Spacer(modifier = Modifier.height(16.dp))
    • Native Android XML
      • Use Margins
  7. Surface

    • Jetpack Compose

    • Surface(color = Color.Blue) { /* Add children here */ }

    • Native Android XML

    • <LinearLayout android:background="@color/blue">
  8. Box

    • Jetpack Compose
    • Box { /* Add children here */ }
    • Native Android XML
    • <FrameLayout>
  9. ScrollableColumn / ScrollableRow

    • Jetpack Compose
      Column(modifier = Modifier.verticalScroll(rememberScrollState())) { /* Add scrollable content here */ }
    • Native Android XML
    • <ScrollView>

  10. AlertDialog

    • Jetpack Compose
    • AlertDialog(onDismissRequest = { /* Handle dismiss */ }, buttons = { /* Add buttons here */ })
    • Native Android XML
    • Custom implementation using AlertDialog.Builder or DialogFragment.
  11. Snackbar

    • Jetpack Compose
    • SnackbarHost { /* Show snackbar using scaffoldState */ }
    • Native Android XML
    • Snackbar.make(view, "Message", Snackbar.LENGTH_SHORT).show()
  12. BottomNavigation

    • Jetpack Compose
    • BottomNavigation { /* Add navigation items here */ }
    • Native Android XML
    • BottomNavigationView

Comparision of android native xml UI components and the Getpack UI components

Certainly I want to see side by side how the old android native xml UI components and the Getpack UI components.  if you guys are started le...