0

Currently, I'm developing Android app (phone only) and using only one size for different screen sizes, ie:

dimens.xml:

<dimen name="button_size">48dp</dimen>

<dimen name="text_size">16sp</dimen>

so in different screen sizes, we have only one size for components. And we go to this result: in small device, a textview can contain 10 chars but in larger device, a textview can contain 20 chars

And some developers use a gradle script to generate multiple dimens files in different folders based on the main dimens file like this:

values-sw320dp

dimens.xml:

<dimen name="button_size">48dp</dimen>

<dimen name="text_size">16sp</dimen>

values-sw480dp

dimens.xml:

<dimen name="button_size">52dp</dimen>

<dimen name="text_size">20sp</dimen>

...

so the system will use the dimens based on device size. And we go to this result: in small device and larger device, a textview can contain the same char, ie: 12 chars.

My question is: which one is better for UI, UX? (using Google Material Design)

Norutan
  • 1,480
  • 2
  • 14
  • 27
  • 1
    https://stackoverflow.com/questions/9877946/text-size-and-different-android-screen-sizes – Amit Vaghela Jun 12 '17 at 09:54
  • @AmitVaghela the solution is old, and I also have taken a look at this page: https://developer.android.com/guide/practices/screens_support.html but what I mean in my question is: which solution is better for UI, UX, and especially with Google Material Design – Norutan Jun 12 '17 at 10:02
  • Allways use different dimens file for different devices and you can check my [this answer](https://stackoverflow.com/a/35311502/2826147) – Amit Vaghela Jun 12 '17 at 10:49
  • @AmitVaghela yes, but it's for tablet and we use it with different layouts, but my question is for phone – Norutan Jun 12 '17 at 11:02
  • it is not for tablet my friend it contains layout and dimens for small screen devices also – Amit Vaghela Jun 12 '17 at 11:04

3 Answers3

1

You can use this library to support multiple screen dimen here

subrahmanyam boyapati
  • 2,836
  • 1
  • 18
  • 28
0

You can try this below, this will set automatically based on device.

?android:attr/textAppearanceMedium - For Medium font ?android:attr/textAppearanceSmall - For Small font

?android:attr/textAppearanceLarge - For Large font

Please check Material guidelines, To ensure usability for people with disabilities, give buttons a height of 36dp and give touchable targets a minimum height of 48dp.

Muthukrishnan Rajendran
  • 11,122
  • 3
  • 31
  • 41
0

Best practice is to use different dimens file for different devices. This will help you application view to be same across devices. If you keep same dimens for different devices then layout problem can also come. In some devices your layout will look perfectly fine but in another it will look very bad.

Android developer site also recommend to use different layout for supporting different devices.

Sonam
  • 572
  • 4
  • 13
  • 1
    checked and taken a look at some guides and they suggested to use `layouts` or `drawables`, found nothing for `dimens` – Norutan Jun 12 '17 at 10:39
  • Create layout ,layout Layoutsw600dp and sw720dp folder create the views and dimens folder change the text for all folder For example – Raj Jun 13 '17 at 08:26