viewlayout

getWidth() and getHeight return zero after onMeasure() (specific devices)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 03:07:44
问题 I noticed that my application's view returns 0 for getWidth() and getHeight() after onMeasure() has already been called. This only happens on a handful of devices, for most android devices the following code works fine. My checkViewAndLoad() function loads a scaled bitmap depending on the size of the view. @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); Log.d("widthMeasureSpec", Integer.toString

getWidth() and getHeight return zero after onMeasure() (specific devices)

大兔子大兔子 提交于 2019-12-05 08:08:06
I noticed that my application's view returns 0 for getWidth() and getHeight() after onMeasure() has already been called. This only happens on a handful of devices, for most android devices the following code works fine. My checkViewAndLoad() function loads a scaled bitmap depending on the size of the view. @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); Log.d("widthMeasureSpec", Integer.toString(MeasureSpec.getSize(widthMeasureSpec))); Log.d("heightMeasureSpec", Integer.toString(MeasureSpec.getSize