java - Custom View Width -


i've created class custom view, , overrode onmeasure method show next. when call getter width , height, returns 0. why happen?

@override     protected void onmeasure(int widthmeasurespec, int heightmeasurespec){         super.onmeasure(widthmeasurespec, heightmeasurespec);         int parentwidth = measurespec.getsize(widthmeasurespec);         int parentheight = measurespec.getsize(heightmeasurespec);         this.setmeasureddimension(parentwidth, parentheight);    } 

the getwidth() , getheight() values available after first full layout pass (onmeasure -> onlayout) if need access values in between use getmeasuredwidth() , getmeasuredheight()


Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

collision detection - C++ library for mesh to mesh intersection: what is available? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -