最近看一些Demo中发现如下现象:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth(); // deprecatedint height = display.getHeight(); // deprecated
查看API 发现:
int getWidth()、int getHeight()方法:(我用的是level 19)
This method was deprecated in API level 13. Use getSize(Point)
instead.
在看一下getSize(Point)方法:
public void getSize (Point outSize)
Gets the size of the display, in pixels.
Note that this value should not be used for computing layouts, since a device will typically have screen decoration (such as a status bar) along the edges of the display that reduce the amount of application space available from the size returned here. Layouts should instead use the window size.
The size is adjusted based on the current rotation of the display.
The size returned by this method does not necessarily represent the actual raw size (native resolution) of the display. The returned size may be adjusted to exclude certain system decoration elements that are always visible. It may also be scaled to provide compatibility with older applications that were originally designed for smaller displays
Parameters
outSize | A Point object to receive the size information. |
---|
相信不会再有warning了吧。。。
若有不足,欢迎一起交流学习。。。