There are ways to get the resolution and density of the screen. But is it possible to calculate view sizes for a specific xml based on this information?

That is, what would the length and width have view with such a screen? How to create an unnoticed layout. And pull out the necessary info from it.

  • one
    I asked this question to the developers of android. The answer is brief - as long as the view does not "calculated" (and it will do it just at the moment before the display), the dimensions are meaningless. What problem are you solving? - KoVadim
  • How nimble you are with a couple of developers :) It seems that I am solving an unsolvable task. I’m already looking for crutches. To the broken bike. If in a nutshell. Then I need to know the height of the element and, depending on this, programmatically add the necessary amount of textview elements there. This is easy to do with a regular view . But I use a third-party library and for some reason, after the view from the library was rendered, I can't add anything new to it. - Bogdan Shulga
  • you can rewrite the library :) - KoVadim
  • If I even knew where to dig. And is there a problem? I already wrote to the author. I will hope that the answer. - Bogdan Shulga

1 answer 1

Screen density

 getResources().getDisplayMetrics().density; 

Screen sizes for api <13

 getWindowManager().getDefaultDisplay().getHeight() getWindowManager().getDefaultDisplay().getWidth() 

For api> 13

 Point point = new Point(); getWindowManager().getDefaultDisplay().getSize(point); point.x; point.y; 
  • Sorry. But this is not exactly what I asked. - Bogdan Shulga