But its in onStart() while the layout happens in onCreate().  There is
no onFinishInflate() for Activities.  How do i make sure that the
inflation has happened?

On Jan 28, 2:52 pm, Romain Guy <romain...@android.com> wrote:
> You are probably calling getLocationInWindow() before the layout happened.
>
>
>
> On Thu, Jan 28, 2010 at 2:50 PM, ClarkBattle <clarkbat...@gmail.com> wrote:
> > I have an app with the following code using android 2.0.1
>
> > int[] loc = new int[2];
>
> > Button btn = (Button) findViewById( R.id.btn3 );
> > if( btn != null )
> >    btn.getLocationInWindow( loc);
>
> > Log.i("Where?","x=" + where[0] + " y=" + where[1] );
>
> > This logs "x=0 y=88" but R.id.btn3 is in the middle of the screen!
>
> > I was experiencing this in android 2.0.1 so I wrote the following test
> > app in android 2.1 that logs the XY coordinates of a button in the
> > middle of the screen.
>
> > This logs "x=0 and y=0"
>
> > public class TestLoc extends Activity
> > {
> >       �...@override
> >        public void onCreate( Bundle savedInstanceState )
> >        {
> >                super.onCreate( savedInstanceState );
> >                setContentView( R.layout.main );
> >        }
>
> >       �...@override
> >        public void onStart()
> >        {
> >                super.onStart();
>
> >                int[] where = new int[2];
> >                Button view = (Button) findViewById( R.id.btnThree );
> >                if( view != null )
> >                {
> >                    view.getLocationInWindow( where );
> >                    Log.i("Where?","x=" + where[0] + " y=" + where[1] );
> >                }
> >        }
> > }
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <TableLayout
> >    xmlns:android="http://schemas.android.com/apk/res/android";
> >    android:layout_width="wrap_content"
> >    android:layout_height="wrap_content" >
>
> >    <TableRow android:id="@+id/rowOne">
> >      <Button android:id="@+id/btnOne"/>
> >    </TableRow>
>
> >    <TableRow android:id="@+id/rowTwo">
> >      <Button android:id="@+id/btnTwo"/>
> >      <Button android:id="@+id/btnThree"/>
> >    </TableRow>
> > </TableLayout>
>
> > Wha's up?  Is there a reliable way to get the window coordinates of
> > any view?
>
> > Thanks for reading,
> > Clark
>
> > --
> > 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
>
> --
> 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

Reply via email to