First we need to compute HEIGHT representations -
iOutdoorCompressedHeight = rlOutdoorSection.getMeasuredHeight();
Use this HEIGHT as the axis around which you want to scale the view.
rlOutdoorSection.setPivotX(0f); rlOutdoorSection.setPivotY(iOutdoorCompressedHeight);
The trick here may be with a measured viewing height.
In Activity calculate height in
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus);
In a FRAGMENT use the global layout receiver -
rlOutdoorSection = (RelativeLayout) vMain .findViewById(R.id.rlOutdoorSection); ViewTreeObserver vtoOutdoor = rlIndoorSection.getViewTreeObserver(); vtoOutdoor.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { iOutdoorCompressedHeight = rlOutdoorSection.getMeasuredHeight(); rlOutdoorSection.setPivotX(0f); rlOutdoorSection.setPivotY(iOutdoorCompressedHeight); } });
Hope this helps someone.
source share