@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { Paint.FontMetrics fontMetrics = getPaint().getFontMetrics(); int height = (getCompoundPaddingTop() + (int)Math.ceil(Math.abs(fontMetrics.top) + Math.abs(fontMetrics.bottom)) + getCompoundPaddingBottom()); final Resources resources = getResources(); String text = loginText; int logInWidth; int width; if (text == null) { text = resources.getString(R.string.com_facebook_loginview_log_in_button_continue); logInWidth = measureButtonWidth(text); width = resolveSize(logInWidth, widthMeasureSpec); if (width < logInWidth) { text = resources.getString(R.string.com_facebook_loginview_log_in_button); } } logInWidth = measureButtonWidth(text); text = logoutText; if (text == null) { text = resources.getString(R.string.com_facebook_loginview_log_out_button); } int logOutWidth = measureButtonWidth(text); width = resolveSize(Math.max(logInWidth, logOutWidth), widthMeasureSpec); setMeasuredDimension(width, height); }