Submitted by martinkoubek
on Tue, 03/08/2016 - 06:46
Calling method getWidth(), getHeight() after onCreate return 0 as the view is not yet positioned correctly in layout. One of the easiest approach to get the width and height is postpone call:
valueTextView = (TextView)findViewById(R.id.include_value);
valueTextView.post(new Runnable() { @Override public void run() { int w = valueTextView.getWidth(); int h = valueTextView.getHeight(); } });
Tags