List of usage examples for android.view View offsetTopAndBottom
public void offsetTopAndBottom(int offset)
From source file:net.nym.napply.library.behavior.HeadOffsetBehavior.java
public void offset(View child, int dy) { int old = offsetTotal; int top = offsetTotal - dy; top = Math.max(top, -child.getHeight()); top = Math.min(top, 0);//from w w w . ja v a 2s . c o m offsetTotal = top; if (old == offsetTotal) { scrolling = false; return; } int delta = offsetTotal - old; child.offsetTopAndBottom(delta); scrolling = true; }
From source file:com.actionbarsherlock.internal.widget.ActionBarContainer.java
@Override public void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); final boolean hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE; if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { final int containerHeight = getMeasuredHeight(); final int tabHeight = mTabContainer.getMeasuredHeight(); if ((mActionBarView.getDisplayOptions() & ActionBar.DISPLAY_SHOW_HOME) == 0) { // Not showing home, put tabs on top. final int count = getChildCount(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child == mTabContainer) continue; if (!mActionBarView.isCollapsed()) { child.offsetTopAndBottom(tabHeight); }/*from www.j av a 2 s . co m*/ } mTabContainer.layout(l, 0, r, tabHeight); } else { mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight); } } boolean needsInvalidate = false; if (mIsSplit) { if (mSplitBackground != null) { mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); needsInvalidate = true; } } else { if (mBackground != null) { mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(), mActionBarView.getRight(), mActionBarView.getBottom()); needsInvalidate = true; } if ((mIsStacked = hasTabs && mStackedBackground != null)) { mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(), mTabContainer.getRight(), mTabContainer.getBottom()); needsInvalidate = true; } } if (needsInvalidate) { invalidate(); } }
From source file:com.hippo.nimingban.widget.PostLayout.java
private void init(Context context) { mDragHelper = ViewDragHelper.create(this, 1.0f, new DragHelperCallback()); mShadowTop = context.getResources().getDrawable(R.drawable.shadow_top); mShadowHeight = LayoutUtils.dp2pix(context, 8); mThreshold = LayoutUtils.dp2pix(context, 48); mHideTypeSendAnimation = new ValueAnimator(); mHideTypeSendAnimation.setDuration(300); mHideTypeSendAnimation.setInterpolator(AnimationUtils2.FAST_SLOW_INTERPOLATOR); mHideTypeSendAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w ww .java2s .c om public void onAnimationUpdate(ValueAnimator animation) { View view = getChildAt(1); if (view != null) { int value = (Integer) animation.getAnimatedValue(); view.offsetTopAndBottom(value - view.getTop()); ((LayoutParams) view.getLayoutParams()).offsetY = value; invalidate(); } } }); mShowTypeSendAnimation = new ValueAnimator(); mShowTypeSendAnimation.setDuration(300); mShowTypeSendAnimation.setInterpolator(AnimationUtils2.FAST_SLOW_INTERPOLATOR); mShowTypeSendAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { View view = getChildAt(1); if (view != null) { int value = (Integer) animation.getAnimatedValue(); view.offsetTopAndBottom(value - view.getTop()); ((LayoutParams) view.getLayoutParams()).offsetY = value; invalidate(); } } }); }
From source file:com.hippo.nimingban.widget.PostLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); for (int i = 0, count = getChildCount(); i < count; i++) { View child = getChildAt(i); if (GONE == child.getVisibility()) { continue; }//from w w w. j a v a 2 s . c om LayoutParams lp = (LayoutParams) child.getLayoutParams(); child.offsetLeftAndRight(lp.offsetX); child.offsetTopAndBottom(lp.offsetY); } }
From source file:com.hippo.nimingban.widget.PostLayout.java
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { View typeSendView = getChildAt(1); if (typeSendView != null) { LayoutParams lp = (LayoutParams) typeSendView.getLayoutParams(); if (lp.hide) { mHideTypeSendAnimation.cancel(); mShowTypeSendAnimation.cancel(); int top = getHeight() - typeSendView.findViewById(R.id.toolbar).getHeight(); typeSendView.offsetTopAndBottom(top - typeSendView.getTop()); lp.offsetY = top;/*from w w w. j a v a2s . co m*/ } } }
From source file:am.widget.multifunctionalrecyclerview.layoutmanager.BothDirectionsScrollLayoutManager.java
@Override public void layoutDecorated(@NonNull View child, int left, int top, int right, int bottom) { super.layoutDecorated(child, left, top, right, bottom); final int offset = computeAnotherDirectionDefaultScrollOffset(); final int move = offset - mOffset; if (move == 0) return;/* w w w .j av a 2s. c o m*/ if (getOrientation() == HORIZONTAL) { child.offsetTopAndBottom(move); } else { child.offsetLeftAndRight(move); } }
From source file:am.widget.multifunctionalrecyclerview.layoutmanager.BothDirectionsScrollLayoutManager.java
@Override public void layoutDecoratedWithMargins(@NonNull View child, int left, int top, int right, int bottom) { super.layoutDecoratedWithMargins(child, left, top, right, bottom); final int offset = computeAnotherDirectionDefaultScrollOffset(); final int move = offset - mOffset; if (move == 0) return;//from w w w.j ava 2s. com if (getOrientation() == HORIZONTAL) { child.offsetTopAndBottom(move); } else { child.offsetLeftAndRight(move); } }
From source file:ch.tutti.android.bottomsheet.ResolverDrawerLayout.java
private float performDrag(float dy) { final float newPos = Math.max(0, Math.min(mCollapseOffset + dy, mCollapsibleHeight)); if (newPos != mCollapseOffset) { dy = newPos - mCollapseOffset;// w w w.j a v a 2 s. co m final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (!lp.ignoreOffset) { child.offsetTopAndBottom((int) dy); } } mCollapseOffset = newPos; mTopOffset += dy; ViewCompat.postInvalidateOnAnimation(this); return dy; } return 0; }
From source file:com.cocosw.accessory.views.adapter.AdapterViewAnimator.java
public void animate() { if (animateCalled) { throw new RuntimeException("animate must only be called once"); }// www .jav a2s . c o m animateCalled = true; final ViewTreeObserver observer = adapterView.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { observer.removeOnPreDrawListener(this); Adapter adapter = adapterView.getAdapter(); final int firstVisiblePosition = adapterView.getFirstVisiblePosition(); for (int i = 0, childCount = adapterView.getChildCount(); i < childCount; i++) { final int position = firstVisiblePosition + i; final long id = adapter.getItemId(position); idToViewMap.remove(id); final View child = adapterView.getChildAt(i); final Rect bounds = viewBounds.get(id); Runnable endAction = new Runnable() { @Override public void run() { ViewCompat.setHasTransientState(child, false); } }; if (bounds != null) { if (callback == null || !callback.onMoveView(adapterView, child, position, id, bounds, endAction)) { final int dx = bounds.left - child.getLeft(); final int dy = bounds.top - child.getTop(); ViewCompat.setTranslationX(child, dx); ViewCompat.setTranslationY(child, dy); ViewCompat.animate(child).setDuration(DURATION_MOVE).translationX(0.0f) .translationY(0.0f).withEndAction(endAction); } } else { if (callback == null || !callback.onAddView(adapterView, child, position, id)) { ViewCompat.setAlpha(child, 0.0f); ViewCompat.animate(child).setDuration(DURATION_ADD).alpha(1.0f); } } } int[] adapterViewLocation = new int[2]; int[] hostViewLocation = new int[2]; final int size = idToViewMap.size(); for (int i = 0; i < size; i++) { final long id = idToViewMap.keyAt(i); final View child = idToViewMap.get(id); ViewCompat.setHasTransientState(child, false); final View viewCopy = new ViewCopy(child); Rect bounds = viewBounds.get(id); if (overlay == null) { ViewGroup parent = (ViewGroup) adapterView.getParent(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) overlay = parent.getOverlay(); adapterView.getLocationOnScreen(adapterViewLocation); parent.getLocationOnScreen(hostViewLocation); } overlay.add(viewCopy); viewCopy.offsetLeftAndRight(adapterViewLocation[0] - hostViewLocation[0]); viewCopy.offsetTopAndBottom(adapterViewLocation[1] - hostViewLocation[1]); if (callback == null || !callback.onRemoveView(adapterView, viewCopy, id, bounds)) { ViewCompat.animate(viewCopy).setDuration(DURATION_REMOVE).alpha(0.0f) .withEndAction(new Runnable() { @Override public void run() { overlay.remove(viewCopy); } }); } } return true; } }); }
From source file:com.tasomaniac.openwith.resolver.ResolverDrawerLayout.java
private float performDrag(float dy) { final float newPos = Math.max(0, Math.min(mCollapseOffset + dy, mCollapsibleHeight + mUncollapsibleHeight)); if (newPos != mCollapseOffset) { dy = newPos - mCollapseOffset;//from w w w. j a v a 2 s. c o m final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (!lp.ignoreOffset) { child.offsetTopAndBottom((int) dy); } } mCollapseOffset = newPos; mTopOffset += dy; ViewCompat.postInvalidateOnAnimation(this); return dy; } return 0; }