Because you are telling the view to measure itself with AT_MOST 0 pixels on both axis. Look at the MeasureSpec class to see what methods you can use to create a proper measure spec.
On Thu, Mar 19, 2009 at 11:26 AM, Bob <bshumsk...@yahoo.com> wrote: > > Sorry to be a dolt but I am still getting 0 for my measuredheight > (ht). What am I doing wrong? > > setContentView(R.layout.simplelinear); > LinearLayout ll= (LinearLayout)this.findViewById(R.id.linearLayout); > ll.forceLayout(); > ll.measure(View.MeasureSpec.AT_MOST, View.MeasureSpec.AT_MOST); > int ht=ll.getMeasuredHeight(); > > > > simplelinear layout: > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:orientation="vertical" > android:id="@+id/linearLayout" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > > > > > </LinearLayout> > On Mar 19, 1:10 pm, Romain Guy <romain...@google.com> wrote: >> You have to measure the widget before you can get its dimension. >> >> >> >> On Thu, Mar 19, 2009 at 11:08 AM, Bob <bshumsk...@yahoo.com> wrote: >> >> > Thanks. What is the proper method to use on the control to get its >> > total size? I have tried getHeight, getMeasuredHeight, and >> > getDrawingRect but they all return 0 to me on the first pass when I >> > need to figure out how much content to put into the control. >> >> > On Mar 19, 11:57 am, Dianne Hackborn <hack...@android.com> wrote: >> >> You almost certainly don't want to do that. It does not tell you the >> >> actually available space (taking into account any screen decorations that >> >> may or may not be showing), just the raw size. You should always use the >> >> view hierarchy layout system to place your UI. >> >> >> On Thu, Mar 19, 2009 at 9:36 AM, Bob <bshumsk...@yahoo.com> wrote: >> >> >> > Thanks, that seems to work. >> >> >> > On Mar 19, 9:54 am, Pd <lotusscr...@gmail.com> wrote: >> >> > > this may work but I've not tested it :-) >> >> >> > > getWindow().getWindowManager().getDefaultDisplay().getWidth(); >> >> > > >> >> > > getWindow().getWindowManager().getDefaultDisplay().getHeight(); >> >> >> > > Bob wrote: >> >> > > > Hi, >> >> > > > How do I get the current screen resolution (width and height)? >> >> >> > > > Thanks, >> >> > > > Bob >> >> >> -- >> >> Dianne Hackborn >> >> Android framework engineer >> >> hack...@android.com >> >> >> Note: please don't send private questions to me, as I don't have time to >> >> provide private support. All such questions should be posted on public >> >> forums, where I and others can see and answer them. >> >> -- >> Romain Guy >> Android framework engineer >> romain...@android.com >> >> Note: please don't send private questions to me, as I don't have time >> to provide private support. All such questions should be posted on >> public forums, where I and others can see and answer them > > > -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---