android - Setting the width of EditText -


i setting width of edittext element fill_parent in xml file, when accessing code, returns 0. want, actual width of element @ run time. how it.

use getmeasuredwidth(): http://developer.android.com/reference/android/view/view.html#getmeasuredwidth%28%29

read here:

when view's measure() method returns, getmeasuredwidth() , getmeasuredheight() values must set, along of view's descendants. view's measured width , measured height values must respect constraints imposed view's parents. guarantees @ end of measure pass, parents accept of children's measurements. parent view may call measure() more once on children. example, parent may measure each child once unspecified dimensions find out how big want be, call measure() on them again actual numbers if sum of children's unconstrained sizes big or small (i.e., if children don't agree among how space each get, parent intervene , set rules on second pass).

http://developer.android.com/guide/topics/ui/how-android-draws.html


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -