In my code i m trying to find the height the textview occupies..
I used OnGlobalLayout for that ..
here is my code

public void onCreate(Bundle savedInstanceState)
{
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   t = new TextView(this);
   ViewTreeObserver vto = t.getViewTreeObserver();
   vto.addOnGlobalLayoutListener(this);
   t.setText("This is to test the text\n Some Text \n
Another ..");
   t.append("\nafter something");
   Toast.makeText(this, " The value at num =
"+num,Toast.LENGTH_SHORT).show();
   setContentView(t);
}

public void onGlobalLayout()
{
  num=t.getHeight();
  Toast.makeText(this, "Hellooo !! height is "+num,
Toast.LENGTH_SHORT).show();
}

The value of num in onCreate() is always zero but atlast in the
onGlobalLayout() , the correct height is getting stored in num but i
cant use it because it is the end of the application .. Is there any
possibility of getting the text length in the middle of the
application ?

Forgive, if there are any mistakes in the above problem..

Thanks, Siva Kumar

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to