views:

32

answers:

1

Hi all,

I have used gesture implementation in my application, my object moves perfectly throughout the screen, during fling, scroll..etc, but sometimes my object goes out of the view and its getting disappear, now i have to restrict the boundary of my gesture object, i have placed this gesture with in a view, i tried to get the width and height of the view and tried to restrict,but i can;t find it right , still the ;object moves out of its boundary....

My viewholder(layout where the gesture is placed) , i tried to get the width and height viewholder.getWidth(),viewholder.getHeight() but both returns 0,

i knew i have gone wrong somewhere, could anyone able to correct me, how i can move further

framelayout = (FrameLayout) findViewById(R.id.LinearLayout_DrawCircle);
framelayout.addView(new DrawTarget(this)); // View 1 (Draws Concentric circle)
framelayout.addView(gestureaction); // View 2 (Draws a bitmap and invokes gesture that can move around)
//trying to find the width and height of the view, so that movement of object can be restricted
 px = framelayout.getWidth();
 py = framelayout.getHeight();
 Log.i(TAG,"Width =" +px + "," + "Height = " +py); //return 0,0

please let me know how to proceed further...

Thanks in advance

A: 

In android a view is assigned Width and Height only when its rendering is complete. So unless your views are rendered atleast once they won't be assigned any width or height. Solution to your problem could be that you set some min Height and width of view so that you have atleast something to work with initially and once your views are rendered you will have width and height of the view to play with.

Amit Chintawar
okay,Thanks a Lot Amit..
Nandagopal T