Java Code Examples for android.support.v4.view.ViewCompat#getY()
The following examples show how to use
android.support.v4.view.ViewCompat#getY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DescriptionAnimation.java From LoyalNativeSlider with MIT License | 6 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void workOnTarget(@Nullable View descriptionLayout) { if (descriptionLayout == null) return; float layoutY = ViewCompat.getY(descriptionLayout); descriptionLayout.setVisibility(View.VISIBLE); ValueAnimator animator = ObjectAnimator.ofFloat( descriptionLayout, "y", (float) (layoutY + descriptionLayout.getHeight()), layoutY) .setDuration(500); if (animation_behavior != null) { animator.setInterpolator(animation_behavior); } animator.start(); }
Example 2
Source File: DraggerView.java From Dragger with Apache License 2.0 | 6 votes |
/** * Detect if the dragView actual position is above the * limit determined with the @param dragLimit. * * @return Use a dimension and compare with the dragged * axis position. */ boolean isDragViewAboveTheLimit() { int parentSize; float viewAxisPosition; switch (dragPosition) { case LEFT: parentSize = dragView.getWidth(); viewAxisPosition = -ViewCompat.getX(dragView) + (parentSize * dragLimit); break; case RIGHT: parentSize = dragView.getWidth(); viewAxisPosition = ViewCompat.getX(dragView) + (parentSize * dragLimit); break; case TOP: default: parentSize = dragView.getHeight(); viewAxisPosition = ViewCompat.getY(dragView) + (parentSize * dragLimit); break; case BOTTOM: parentSize = dragView.getHeight(); viewAxisPosition = -ViewCompat.getY(dragView) + (parentSize * dragLimit); break; } return parentSize < viewAxisPosition; }
Example 3
Source File: ViewUtil.java From Tok-Android with GNU General Public License v3.0 | 5 votes |
public static float getY(final @NonNull View v) { if (Build.VERSION.SDK_INT >= 11) { return ViewCompat.getY(v); } else { return ((ViewGroup.MarginLayoutParams) v.getLayoutParams()).topMargin; } }
Example 4
Source File: ViewUtil.java From Silence with GNU General Public License v3.0 | 5 votes |
public static float getY(final @NonNull View v) { if (VERSION.SDK_INT >= 11) { return ViewCompat.getY(v); } else { return ((ViewGroup.MarginLayoutParams)v.getLayoutParams()).topMargin; } }
Example 5
Source File: StickyHeaderDecoration.java From Silence with GNU General Public License v3.0 | 5 votes |
private int getChildY(RecyclerView parent, View child) { if (VERSION.SDK_INT < 11) { Rect rect = new Rect(); parent.getChildVisibleRect(child, rect, null); return rect.top; } else { return (int)ViewCompat.getY(child); } }
Example 6
Source File: MaterialViewPagerAnimator.java From MaterialViewPager with Apache License 2.0 | 5 votes |
/** * move the toolbarlayout (containing toolbar & tabs) * following the current scroll */ private void followScrollToolbarLayout(float yOffset) { if (mHeader.toolbar.getBottom() == 0) { return; } if (toolbarJoinsTabs()) { if (firstScrollValue == Float.MIN_VALUE) { firstScrollValue = yOffset; } float translationY = firstScrollValue - yOffset; if (translationY > 0) { translationY = 0; } log("translationY " + translationY); ViewCompat.setTranslationY(mHeader.toolbarLayout, translationY); } else { ViewCompat.setTranslationY(mHeader.toolbarLayout, 0); justToolbarAnimated = false; } followScrollToolbarIsVisible = (ViewCompat.getY(mHeader.toolbarLayout) >= 0); }
Example 7
Source File: FabSheetWindow.java From android-md-core with Apache License 2.0 | 5 votes |
FabInfo(FloatingActionButton fab) { int[] location = new int[2]; fab.getLocationInWindow(location); width = fab.getMeasuredWidth(); height = fab.getMeasuredHeight(); topLeft = new Pointer(location[0], location[1]); center = new Pointer(topLeft.x + width / 2, topLeft.y + height / 2); bottomRight = new Pointer(topLeft.x + width, topLeft.y + height); relativeTopLeft = new Pointer(ViewCompat.getX(fab), ViewCompat.getY(fab)); relativeCenter = new Pointer(relativeTopLeft.x + width / 2, relativeTopLeft.y + height / 2); relativeBottomRight = new Pointer(relativeTopLeft.x + width, relativeTopLeft.y + height); radius = Math.min(width / 2, MdCompat.dpToPx(FAB_SIZE)); }
Example 8
Source File: HeaderAbsListViewScrollListener.java From AbsListViewHelper with MIT License | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem == 0) { final View firstView = view.getChildAt(0); if (firstView != null) { translationY = ViewCompat.getY(firstView) - (paddingTop / 2) - headerView.getHeight(); ViewCompat.setTranslationY(headerView, translationY); } } }
Example 9
Source File: FooterAbsListViewScrollListener.java From AbsListViewHelper with MIT License | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem + visibleItemCount >= totalItemCount) { final View lastView = view.getChildAt(view.getChildCount() - 1); if (lastView != null) { translationY = footerView.getHeight() - (view.getHeight() - (ViewCompat.getY(lastView) + lastView.getHeight())) + (paddingBottom / 2); ViewCompat.setTranslationY(footerView, translationY); } } else { translationY = footerView.getHeight(); ViewCompat.setTranslationY(footerView, translationY); } }
Example 10
Source File: ViewUtils.java From Expert-Android-Programming with MIT License | 4 votes |
public static float centerY(View view) { return ViewCompat.getY(view) + view.getHeight() / 2f; }
Example 11
Source File: SheetLayout.java From HaiNaBaiChuan with Apache License 2.0 | 4 votes |
private float centerY(View view) { return ViewCompat.getY(view) + view.getHeight() / 2f; }
Example 12
Source File: Utils.java From android-md-core with Apache License 2.0 | 4 votes |
public static float centerY(View view) { return ViewCompat.getY(view) + view.getMeasuredHeight() / 2; }