Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.48 KB  |  hits: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. EditText: getHeight() after setText()
  2. final TextView tv = (TextView) findViewById(R.id.myTextView);
  3.     ViewTreeObserver vto = tv.getViewTreeObserver();
  4.     vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
  5.         @Override
  6.         public void onGlobalLayout() {
  7.             Toast.makeText(MyActivity.this, tv.getWidth() + " x " + tv.getHeight(), Toast.LENGTH_LONG).show();
  8.             tv.getViewTreeObserver().removeGlobalOnLayoutListener(this);
  9.         }
  10.     });