在Android Studio上,它一直在说setBackgroundDrawable()以及getWidth和getHeight都被弃用了。
我该如何解决这个问题?
ivImage.setBackgroundDrawable(gd);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();发布于 2016-02-07 19:20:10
只需阅读该函数的文档,然后按照它们告诉您的做。对于ImageView.setBackgroundDrawable,文档告诉您使用setBackground
1级接口增加
公共空setBackgroundDrawable (可绘制背景)
此方法在API级别16中已弃用。请改用setBackground(可绘制的)。
对于Display上的getWidth和getHeight,文档告诉您这样做:
在
级别1中添加了公共int getWidth ()
此方法在API级别13中已弃用。请改用getSize(Point)。
这可以归结为
Point point = null;
getWindowManager().getDefaultDisplay().getSize(point);
int width = point.x;
int height = point.y;https://stackoverflow.com/questions/35252706
复制相似问题