I am designing a UI in Android Studio using XML layouts. However, the UI is not rendering consistently across different devices, especially between mobile and tablet devices. The UI looks fine on tablets but appears distorted or oversized on mobile devices. I want to ensure that the UI maintains a consistent and visually appealing appearance across all screen sizes.
I have explored using dimension resources (dimens.xml) to manage sizing for different screen sizes. However, I am struggling to determine the appropriate sizes for various UI elements, such as TextViews, Switches, and CardViews, to ensure consistent scaling across devices. For instance, I want the text size in TextViews to be 14sp on small devices and 24sp on tablets. How can I effectively determine these sizes for all UI elements and apply them consistently?
Additionally, I am unsure if each device type requires a separate dimensions file. If so, how should I create and manage these files?
Additional details:
I am using Android Studio version Iguana | 2023.2.1.
I am targeting API level 28 and above.
I have tried using android:autoSizeTextType
for TextViews, but it doesn’t seem to produce the desired results consistently.
Please provide guidance on how to achieve consistent UI sizing across different screen sizes in Android using XML layouts.
Thank you for your assistance.