Search code examples
androidxmlkotlinandroid-fragmentsandroid-activity

More activities or 1-2 activities and multiple fragments? Jetpack compose or XML or both?


I'm building a simple app that's basically text input and multiple-choice input from a recycler view, pulled from an api. Then exporting the form answers to a pdf, uploading that to a database and accessing the database.

That being said, I've only worked with XML and with multiple activities but not with fragments. So, my questions re: Is there a rule of thumb for when to use activity vs when to use a fragment? Should I continue with XML since I'm doing basic things here or is it worth learning jetpack compose since I am on a deadline?


Solution

  • Is there a rule of thumb for when to use activity vs when to use a fragment?

    The fragments were created to make supporting different screen sizes easier, so if you are planning on making apps that do support all screen sizes, you would use fragments

    Example: gmail on a phone and a tablet:

    enter image description hereenter image description here

    As you see on the tablet there are more componenets visible, which were (probably) created with fragments

    Should I continue with XML since I'm doing basic things here or is it worth learning jetpack compose since I am on a deadline?

    As a person that had to switch to compose due to work related reasons, I would recommend sticking to XML, making a smooth working app with low experience in compose will be a bit tricky (it took me more than a month to get used to compose)