Java Code Examples for android.support.v4.view.ViewCompat#getX()

The following examples show how to use android.support.v4.view.ViewCompat#getX() . 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: DraggerView.java    From Dragger with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: ViewUtil.java    From Tok-Android with GNU General Public License v3.0 5 votes vote down vote up
public static float getX(final @NonNull View v) {
    if (Build.VERSION.SDK_INT >= 11) {
        return ViewCompat.getX(v);
    } else {
        return ((LinearLayout.LayoutParams) v.getLayoutParams()).leftMargin;
    }
}
 
Example 3
Source File: ViewUtil.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
public static float getX(final @NonNull View v) {
  if (VERSION.SDK_INT >= 11) {
    return ViewCompat.getX(v);
  } else {
    return ((LayoutParams)v.getLayoutParams()).leftMargin;
  }
}
 
Example 4
Source File: FabSheetWindow.java    From android-md-core with Apache License 2.0 5 votes vote down vote up
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 5
Source File: ViewUtils.java    From Expert-Android-Programming with MIT License 4 votes vote down vote up
public static float centerX(View view) {
    return ViewCompat.getX(view) + view.getWidth() / 2f;
}
 
Example 6
Source File: SheetLayout.java    From HaiNaBaiChuan with Apache License 2.0 4 votes vote down vote up
private float centerX(View view) {
    return ViewCompat.getX(view) + view.getWidth() / 2f;
}
 
Example 7
Source File: Utils.java    From android-md-core with Apache License 2.0 4 votes vote down vote up
public static float centerX(View view) {
  return ViewCompat.getX(view) + view.getMeasuredWidth() / 2;
}