Exemplo n.º 1
0
  @Override
  public void onLayout(float l, float t, float r, float b) {

    LayoutParams childLayoutParams = child.getLayoutParams();
    childLayoutParams.computeFrame(layoutParams);
    child.layout(
        childLayoutParams.mComputedLeft
            + layoutParams.computeMesure(childLayoutParams.getLayoutMarginLeft())
            + layoutParams.computeMesure(childLayoutParams.getLayoutPaddingLeft()),
        childLayoutParams.mComputedTop
            + layoutParams.computeMesure(childLayoutParams.getLayoutMarginTop())
            + layoutParams.computeMesure(childLayoutParams.getLayoutPaddingTop()),
        childLayoutParams.mComputedRight
            - layoutParams.computeMesure(childLayoutParams.getLayoutMarginRight())
            - layoutParams.computeMesure(childLayoutParams.getLayoutPaddingRight()),
        childLayoutParams.mComputedBottom
            - layoutParams.computeMesure(childLayoutParams.getLayoutMarginBottom())
            - layoutParams.computeMesure(childLayoutParams.getLayoutPaddingBottom()));

    float oldCenterX = oldWidth / 2 - scrollOffsetX;
    float oldCenterY = oldHeight / 2 - scrollOffsetY;

    setScrollCenter(new Point(oldCenterX, oldCenterY));

    oldWidth = layoutParams.getWidth();
    oldHeight = layoutParams.getHeight();
  }