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

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

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