/** Call when the ViewGroup is layout. */ @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); int galleryCenter = getCenterOfGallery(); View v = this.getChildAt(0); int height = (null != v) ? v.getMeasuredHeight() : 50; int top = galleryCenter - height / 2; int bottom = top + height; mSelectorBound.set(getPaddingLeft(), top, getWidth() - getPaddingRight(), bottom); }