Android: Get the screen resolution / pixels as integer values

前端 未结 5 1485
再見小時候
再見小時候 2020-12-05 08:38

this is a really simple question on which I\'ve found no answer :/ How can I quickly access the screen resolution (width, height) as integer values?

I\'ve tried this

5条回答
  •  死守一世寂寞
    2020-12-05 09:29

    The easiest way will be to implement onSizeChanged. You are probably getting a value of 0 because the view hasn't initialized yet. You can't call the above code in the View constructor for example.

提交回复
热议问题