3

The same screen size, for example 10' can have different resolution: 1280x800 and 2560x1800. This way, both devices fit the sw720 and get the dimens from dimens-sw720 folder, but this way the views are either too big on the smaller device and normal on the bigger device, or normal on the small device and too small on the bigger device. How do I make the app tell the difference between both screens so they use different dimens? If xlarge-mdpi and xlarge-xhdpi are used instead of sw-720, this screws up the views on a 5.5' device I have here (not sure if that happens to all 5.5' devices).

I already spent a good chunk of my time looking for an answer here, rereading the documentation and consulting with other devs, but so far no one was able to give me an answer. One of the answers here says that if the screens are the same size, but the resolution is different and I've used dp, the view should be fine on both devices, but that's not the case here. These are the questions I went through and followed every related questions to them: Q1, Q2, Q3, Q4 and ofc the main documentation link, which contains links to more detailed information about supporting different screen resolutions. Am I missing something here?

Noterezeck
  • 422
  • 4
  • 17

1 Answers1

1

I also faced this issue before 6 months. I ended up with this sdp library. This library made it very simple to make app responsive for all screens.

And what you have to do is just use like _10sdp instead of 10dp. That's all!

enter image description here

Add this library to your gradle.

dependencies {
  implementation 'com.intuit.sdp:sdp-android:1.0.5'
}
Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
  • Ill definitely give it a shot. Thanks for the fast response! – Noterezeck Jul 16 '18 at 12:11
  • useless library, it can be done easily with ConstrainLayout –  Jul 16 '18 at 12:12
  • I don't use Constraint layout still. Because `LinearLayout` is more controllable. – Khemraj Sharma Jul 16 '18 at 12:14
  • What would be preferred way to for old project having hundreds of layouts? 1> convert layouts to Constraint or 2> just change `dp` to `sdp` in your `dimen.xml`. – Khemraj Sharma Jul 16 '18 at 12:22
  • how do you know how many layout topic starter has? also he should keep images in separated drawable folders -xhdpi -mdpi so on, instead of adding another one useless library –  Jul 16 '18 at 12:59
  • Don't shout!, Yes Android suggest to keep images in particular folder. But never do that. Because it will increase app size `x times` you add a new folder. Solution is to take image `100*100` if you need 50*50, and place it in `xdpi`. Image will never be stretched. And your app will not get huge size. – Khemraj Sharma Jul 16 '18 at 13:07
  • 2
    you prefer LinearLayout to ConstraintLayout because it's hard for you and you never " keep images in particular folder" but uses weird library instead- lol ok,it's your decision –  Jul 16 '18 at 13:15
  • Because i don't want to convert 22 projects to ConstraintLayout. And yes ConstraintLayout has great features, no doubt. And i use it too. – Khemraj Sharma Jul 16 '18 at 13:17