List of usage examples for android.view View getTop
@ViewDebug.CapturedViewProperty public final int getTop()
From source file:com.actionbarsherlock.internal.widget.IcsAdapterView.java
/** * Remember enough information to restore the screen state when the data has * changed.//from ww w. ja v a 2s . c om * */ void rememberSyncState() { if (getChildCount() > 0) { mNeedSync = true; mSyncHeight = mLayoutHeight; if (mSelectedPosition >= 0) { // Sync the selection state View v = getChildAt(mSelectedPosition - mFirstPosition); mSyncRowId = mNextSelectedRowId; mSyncPosition = mNextSelectedPosition; if (v != null) { mSpecificTop = v.getTop(); } mSyncMode = SYNC_SELECTED_POSITION; } else { // Sync the based on the offset of the first view View v = getChildAt(0); T adapter = getAdapter(); if (mFirstPosition >= 0 && mFirstPosition < adapter.getCount()) { mSyncRowId = adapter.getItemId(mFirstPosition); } else { mSyncRowId = NO_ID; } mSyncPosition = mFirstPosition; if (v != null) { mSpecificTop = v.getTop(); } mSyncMode = SYNC_FIRST_POSITION; } } }
From source file:cn.bingoogolapple.androidcommon.adapter.BGADivider.java
private void drawVertical(Canvas canvas, RecyclerView parent, BGAHeaderAndFooterAdapter headerAndFooterAdapter, int itemCount, int realItemCount) { int dividerLeft = parent.getPaddingLeft() + mMarginLeft; int dividerRight = parent.getWidth() - parent.getPaddingRight() - mMarginRight; View itemView; RecyclerView.LayoutParams itemLayoutParams; int realChildAdapterPosition; for (int childPosition = 0; childPosition < itemCount; childPosition++) { itemView = parent.getChildAt(childPosition); if (itemView == null || itemView.getLayoutParams() == null) { continue; }/*ww w .j a va 2s .c om*/ int childAdapterPosition = parent.getChildAdapterPosition(itemView); realChildAdapterPosition = getRealChildAdapterPosition(childAdapterPosition, headerAndFooterAdapter); if (isNeedSkip(childAdapterPosition, headerAndFooterAdapter, realChildAdapterPosition, realItemCount)) { continue; } itemLayoutParams = (RecyclerView.LayoutParams) itemView.getLayoutParams(); int dividerBottom = itemView.getTop() - itemLayoutParams.topMargin; if (mDelegate != null && mDelegate.isNeedCustom(realChildAdapterPosition, realItemCount)) { mDelegate.drawVertical(this, canvas, dividerLeft, dividerRight, dividerBottom, realChildAdapterPosition, realItemCount); } else { drawVertical(canvas, dividerLeft, dividerRight, dividerBottom); } } }
From source file:com.android.hcframe.DraggableGridViewPager.java
private void animateDragged() { if (mLastDragged >= 0) { final View v = getChildAt(mLastDragged); final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); r.inset(-r.width() / 20, -r.height() / 20); v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY)); v.layout(r.left, r.top, r.right, r.bottom); AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2); scale.setDuration(ANIMATION_DURATION); AlphaAnimation alpha = new AlphaAnimation(1, .5f); alpha.setDuration(ANIMATION_DURATION); animSet.addAnimation(scale);//from www . ja v a2s .c o m animSet.addAnimation(alpha); animSet.setFillEnabled(true); animSet.setFillAfter(true); v.clearAnimation(); v.startAnimation(animSet); } }
From source file:android.support.design.widget.CollapsingToolbarLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (mLastInsets != null) { // Shift down any views which are not set to fit system windows final int insetTop = mLastInsets.getSystemWindowInsetTop(); for (int i = 0, z = getChildCount(); i < z; i++) { final View child = getChildAt(i); if (!ViewCompat.getFitsSystemWindows(child)) { if (child.getTop() < insetTop) { // If the child isn't set to fit system windows but is drawing within // the inset offset it down ViewCompat.offsetTopAndBottom(child, insetTop); }/*from w w w.j a v a 2s. c o m*/ } } } // Update the collapsed bounds by getting it's transformed bounds if (mCollapsingTitleEnabled && mDummyView != null) { // We only draw the title if the dummy view is being displayed (Toolbar removes // views if there is no space) mDrawCollapsingTitle = ViewCompat.isAttachedToWindow(mDummyView) && mDummyView.getVisibility() == VISIBLE; if (mDrawCollapsingTitle) { final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; // Update the collapsed bounds final int maxOffset = getMaxOffsetForPinChild( mToolbarDirectChild != null ? mToolbarDirectChild : mToolbar); ViewGroupUtils.getDescendantRect(this, mDummyView, mTmpRect); mCollapsingTextHelper.setCollapsedBounds( mTmpRect.left + (isRtl ? mToolbar.getTitleMarginEnd() : mToolbar.getTitleMarginStart()), mTmpRect.top + maxOffset + mToolbar.getTitleMarginTop(), mTmpRect.right + (isRtl ? mToolbar.getTitleMarginStart() : mToolbar.getTitleMarginEnd()), mTmpRect.bottom + maxOffset - mToolbar.getTitleMarginBottom()); // Update the expanded bounds mCollapsingTextHelper.setExpandedBounds(isRtl ? mExpandedMarginEnd : mExpandedMarginStart, mTmpRect.top + mExpandedMarginTop, right - left - (isRtl ? mExpandedMarginStart : mExpandedMarginEnd), bottom - top - mExpandedMarginBottom); // Now recalculate using the new bounds mCollapsingTextHelper.recalculate(); } } // Update our child view offset helpers. This needs to be done after the title has been // setup, so that any Toolbars are in their original position for (int i = 0, z = getChildCount(); i < z; i++) { getViewOffsetHelper(getChildAt(i)).onViewLayout(); } // Finally, set our minimum height to enable proper AppBarLayout collapsing if (mToolbar != null) { if (mCollapsingTitleEnabled && TextUtils.isEmpty(mCollapsingTextHelper.getText())) { // If we do not currently have a title, try and grab it from the Toolbar mCollapsingTextHelper.setText(mToolbar.getTitle()); } if (mToolbarDirectChild == null || mToolbarDirectChild == this) { setMinimumHeight(getHeightWithMargins(mToolbar)); } else { setMinimumHeight(getHeightWithMargins(mToolbarDirectChild)); } } updateScrimVisibility(); }
From source file:android.support.v7.internal.widget.SpinnerCompat.java
@Override public int getBaseline() { View child = null; if (getChildCount() > 0) { child = getChildAt(0);// w w w .j ava2 s. co m } else if (mAdapter != null && mAdapter.getCount() > 0) { child = makeView(0, false); mRecycler.put(0, child); } if (child != null) { final int childBaseline = child.getBaseline(); return childBaseline >= 0 ? child.getTop() + childBaseline : -1; } else { return -1; } }
From source file:com.android.tv.menu.MenuLayoutManager.java
private void dumpChildren(String prefix) { int position = 0; for (MenuRowView view : mMenuRowViews) { View title = view.getChildAt(0); View contents = view.getChildAt(1); Log.d(TAG, prefix + " position=" + position++ + " rowView={visiblility=" + view.getVisibility() + ", alpha=" + view.getAlpha() + ", translationY=" + view.getTranslationY() + ", left=" + view.getLeft() + ", top=" + view.getTop() + ", right=" + view.getRight() + ", bottom=" + view.getBottom() + "}, title={visiblility=" + title.getVisibility() + ", alpha=" + title.getAlpha() + ", translationY=" + title.getTranslationY() + ", left=" + title.getLeft() + ", top=" + title.getTop() + ", right=" + title.getRight() + ", bottom=" + title.getBottom() + "}, contents={visiblility=" + contents.getVisibility() + ", alpha=" + contents.getAlpha() + ", translationY=" + contents.getTranslationY() + ", left=" + contents.getLeft() + ", top=" + contents.getTop() + ", right=" + contents.getRight() + ", bottom=" + contents.getBottom() + "}"); }// w ww. j a va2 s.c o m }
From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java
/** * Tests scrollability within child views of v given a delta of dx. * * @param v View to test for horizontal scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dx Delta scrolled in pixels//from ww w . j a v a 2 s .c om * @param x X coordinate of the active touch point * @param y Y coordinate of the active touch point * @return true if child views of v can be scrolled by delta of dx. */ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.pitchedapps.primenumbercalculator.Calculator.java
License:asdf
private void reveal(View sourceView, AnimatorListener listener) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay(); final Rect displayRect = new Rect(); mDisplayView.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(this); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(themeClearAccent); groupOverlay.add(revealView);/*from w ww.j a va 2s . c om*/ final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); alphaAnimator.addListener(listener); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); }
From source file:com.android.widget.SlidingPaneLayout.java
@Override public void draw(Canvas c) { super.draw(c); final View shadowView = getChildCount() > 1 ? getChildAt(1) : null; if (shadowView == null || mShadowDrawable == null) { // No need to draw a shadow if we don't have one. return;/* w ww.j ava 2 s. c om*/ } final int shadowHeight = mShadowDrawable.getIntrinsicHeight(); final int right = shadowView.getRight(); final int left = shadowView.getLeft(); final int bottom = shadowView.getTop(); final int top = bottom - shadowHeight; mShadowDrawable.setBounds(left, top, right, bottom); mShadowDrawable.draw(c); }
From source file:com.chao.facebookzc.widget.PickerFragment.java
void updateAdapter(SimpleGraphObjectCursor<T> data) { if (adapter != null) { // As we fetch additional results and add them to the table, we do not // want the items displayed jumping around seemingly at random, frustrating the user's // attempts at scrolling, etc. Since results may be added anywhere in // the table, we choose to try to keep the first visible row in a fixed // position (from the user's perspective). We try to keep it positioned at // the same offset from the top of the screen so adding new items seems // smoother, as opposed to having it "snap" to a multiple of row height // We use the second row, to give context above and below it and avoid // cases where the first row is only barely visible, thus providing little context. // The exception is where the very first row is visible, in which case we use that. View view = listView.getChildAt(1); int anchorPosition = listView.getFirstVisiblePosition(); if (anchorPosition > 0) { anchorPosition++;// w w w .j av a 2 s . c o m } GraphObjectAdapter.SectionAndItem<T> anchorItem = adapter.getSectionAndItem(anchorPosition); final int top = (view != null && anchorItem.getType() != GraphObjectAdapter.SectionAndItem.Type.ACTIVITY_CIRCLE) ? view.getTop() : 0; // Now actually add the results. boolean dataChanged = adapter.changeCursor(data); if (view != null && anchorItem != null) { // Put the item back in the same spot it was. final int newPositionOfItem = adapter.getPosition(anchorItem.sectionKey, anchorItem.graphObject); if (newPositionOfItem != -1) { listView.setSelectionFromTop(newPositionOfItem, top); } } if (dataChanged && onDataChangedListener != null) { onDataChangedListener.onDataChanged(PickerFragment.this); } } }