If you want to get the width or height of a view in activty you can get in this method..
yourview.getHeight();
returns zero(0) after initialization of the button because after adding it to the window only it has a width..in the below method you can height and width of a view..
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
yourview.getHeight();
yourview.getWidth();
}