public static int getMenuBarWidth(Context context) { if (GraphicUtilityClass.isLandscape(context)) { return GraphicUtilityClass.getMinTouchWidth(context); } else { return GraphicUtilityClass.getDisplayWidth(context); } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); synchronized (this) { // System.out.println("ScreenMenuBar: onMeasure _buttons length=" + _buttons.length); if (_buttons != null && _buttons.length > 0) { int h_interval = 0; int v_interval = 0; if (_landscape_mode) { v_interval = height / _buttons.length; } else { h_interval = width / _buttons.length; } int max_size = 0; for (int i = 0; i < _buttons.length; i++) { if (_landscape_mode) { _buttons[i].measure( MeasureSpec.makeMeasureSpec( GraphicUtilityClass.getMinTouchWidth(getContext()), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(v_interval, MeasureSpec.AT_MOST)); if (max_size < _buttons[i].getMeasuredWidth()) { max_size = _buttons[i].getMeasuredWidth(); } } else { _buttons[i].measure( MeasureSpec.makeMeasureSpec(h_interval, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); if (max_size < _buttons[i].getMeasuredHeight()) { max_size = _buttons[i].getMeasuredHeight(); } } } if (_landscape_mode) { super.setMeasuredDimension(max_size, height); } else { super.setMeasuredDimension(width, max_size); } } else { super.setMeasuredDimension(0, 0); } } }