本文整理汇总了Java中android.view.View.getY方法的典型用法代码示例。如果您正苦于以下问题:Java View.getY方法的具体用法?Java View.getY怎么用?Java View.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: maybeInitProperties
import android.view.View; //导入方法依赖的package包/类
@SuppressLint("PrivateResource")
private void maybeInitProperties(ImageView child, View dependency) {
if (startYPosition == 0)
startYPosition = (int) (dependency.getY());
if (finalYPosition == 0)
finalYPosition = (dependency.getHeight() / 2);
if (startHeight == 0)
startHeight = child.getHeight();
if (finalHeight == 0)
finalHeight = context.getResources().getDimensionPixelOffset(R.dimen.image_small_width);
if (startXPosition == 0)
startXPosition = (int) (child.getX() + (child.getWidth() / 2));
if (finalXPosition == 0)
finalXPosition = context.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + (finalHeight / 2);
if (startToolbarPosition == 0)
startToolbarPosition = dependency.getY() + (dependency.getHeight() / 2);
}
示例2: createShowItemAnimator
import android.view.View; //导入方法依赖的package包/类
private Animator createShowItemAnimator(View item) {
float dx = fab.getX() - item.getX();
float dy = fab.getY() - item.getY();
item.setRotation(0f);
item.setTranslationX(dx);
item.setTranslationY(dy);
Animator anim = ObjectAnimator.ofPropertyValuesHolder(
item,
// AnimatorUtils.rotation(0f, 720f),
AnimatorUtils.translationX(dx, 0f),
AnimatorUtils.translationY(dy, 0f)
);
return anim;
}
示例3: maybeInitProperties
import android.view.View; //导入方法依赖的package包/类
private void maybeInitProperties(ImageView child, View dependency) {
if (mStartYPosition == 0)
mStartYPosition = (int) (dependency.getY());
if (mFinalYPosition == 0)
mFinalYPosition = (dependency.getHeight() /2);
if (mStartHeight == 0)
mStartHeight = child.getHeight();
if (mStartXPosition == 0)
mStartXPosition = (int) (child.getX() + (child.getWidth() / 2));
if (mFinalXPosition == 0)
mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);
if (mStartToolbarPosition == 0)
mStartToolbarPosition = dependency.getY();
if (mChangeBehaviorPoint == 0) {
mChangeBehaviorPoint = (child.getHeight() - mCustomFinalHeight) / (2f * (mStartYPosition - mFinalYPosition));
}
}
示例4: createAnimationImpl
import android.view.View; //导入方法依赖的package包/类
@Override
@Nullable Animation createAnimationImpl(View view, int x, int y, int width, int height) {
boolean animateLocation = view.getX() != x || view.getY() != y;
boolean animateSize = view.getWidth() != width || view.getHeight() != height;
if (!animateLocation && !animateSize) {
return null;
} else if (animateLocation && !animateSize && USE_TRANSLATE_ANIMATION) {
// Use GPU-accelerated animation, however we loose the ability to resume interrupted
// animation where it was left off. We may be able to listen to animation interruption
// and set the layout manually in this case, so that next animation kicks off smoothly.
return new TranslateAnimation(view.getX() - x, 0, view.getY() - y, 0);
} else {
// Animation is sub-optimal for perf, but scale transformation can't be use in this case.
return new PositionAndSizeAnimation(view, x, y, width, height);
}
}
示例5: calcScrollInfo
import android.view.View; //导入方法依赖的package包/类
private ScrollInfo calcScrollInfo(View movingView) {
ScrollInfo result = new ScrollInfo();
float dx = movingView.getX() - mChildInitX;
float dy = movingView.getY() - mChildInitY;
int direction;
if (Float.compare(dx, 0) == 0 && Float.compare(dy, 0) == 0) {
direction = StackCardsView.SWIPE_NONE;
} else {
if (Math.abs(dx) * SLOPE > Math.abs(dy)) {
direction = dx > 0 ? StackCardsView.SWIPE_RIGHT : StackCardsView.SWIPE_LEFT;
} else {
direction = dy > 0 ? StackCardsView.SWIPE_DOWN : StackCardsView.SWIPE_UP;
}
}
log(TAG, "calcScrollInfo,direction=" + direction + ",dx=" + dx + ",dy=" + dy);
result.direction = direction;
double distance = Math.sqrt(dx * dx + dy * dy);
float dismiss_distance = mSwipeView.getDismissDistance();
if (distance >= dismiss_distance) {
result.progress = 1;
} else {
result.progress = (float) distance / dismiss_distance;
}
return result;
}
示例6: getHeaderTop
import android.view.View; //导入方法依赖的package包/类
private int getHeaderTop(RecyclerView parent, View child, View header, int adapterPos, int layoutPos) {
int headerHeight = getHeaderHeightForLayout(header);
int top = ((int) child.getY()) - headerHeight;
if (layoutPos == 0) {
final int count = parent.getChildCount();
for (int i = 1; (i < count); i++) {
int adapterPosHere = parent.getChildAdapterPosition(parent.getChildAt(i));
if (adapterPosHere != RecyclerView.NO_POSITION && hasHeader(adapterPosHere)) {
final View next = parent.getChildAt(i);
final int offset = ((int) next.getY()) - (header.getHeight() + getHeaderHeightForLayout(getHeader(parent, adapterPosHere).itemView));
if (offset < 0) {
return offset;
}
break;
}
}
}
top = Math.max(0, top);
return top;
}
示例7: setChildRotationVertical
import android.view.View; //导入方法依赖的package包/类
/**
* Given that the is {@link Orientation#VERTICAL}, apply rotation if rotation is enabled.
*/
private void setChildRotationVertical(@Gravity int gravity, View child, int radius, Point center) {
if (!rotate) {
child.setRotation(0);
return;
}
boolean childPastCenter = (child.getY() + child.getHeight() / 2) > center.y;
float directionMult;
if (gravity == Gravity.END) {
directionMult = childPastCenter ? -1 : 1;
} else {
directionMult = childPastCenter ? 1 : -1;
}
final float opposite = Math.abs(child.getY() + child.getHeight() / 2 - center.y);
child.setRotation((float) (directionMult * Math.toDegrees(Math.asin(opposite / radius))));
}
示例8: onLayoutFinished
import android.view.View; //导入方法依赖的package包/类
@Override
public void onLayoutFinished(View child, RecyclerView parent) {
// Figure out % progress from top to bottom.
float centerOffset = (child.getHeight() / 2.0f) / parent.getHeight();
float yRelativeToCenterOffset = (child.getY() / parent.getHeight()) + centerOffset;
// Normalize for center.
float progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset);
// Adjust to the maximum scale.
progressToCenter = Math.min(progressToCenter, MAX_ICON_PROGRESS);
child.setScaleX(1 - progressToCenter);
child.setScaleY(1 - progressToCenter);
}
示例9: getY
import android.view.View; //导入方法依赖的package包/类
public static float getY(View view) {
if (View10.NEED_PROXY) {
return View10.wrap(view).getY();
} else {
return view.getY();
}
}
示例10: isChildUnder
import android.view.View; //导入方法依赖的package包/类
private static boolean isChildUnder(View child, float x, float y) {
final float left = child.getX();
final float top = child.getY();
final float right = left + child.getWidth();
final float bottom = top + child.getHeight();
return x >= left && y >= top && x < right && y < bottom;
}
示例11: getHeaderTop
import android.view.View; //导入方法依赖的package包/类
private int getHeaderTop(RecyclerView parent, View child, View header, int adapterPos, int layoutPos) {
int headerHeight = getHeaderHeightForLayout(header);
int top = ((int) child.getY()) - headerHeight;
if (layoutPos == 0) {
final int count = parent.getChildCount();
final long currentId = mListener.getHeaderId(adapterPos);
// find next view with header and compute the offscreen push if needed
for (int i = 1; i < count; i++) {
int adapterPosHere = parent.getChildAdapterPosition(parent.getChildAt(i));
if (adapterPosHere != RecyclerView.NO_POSITION) {
long nextId = mListener.getHeaderId(adapterPosHere);
if (nextId != currentId) {
final View next = parent.getChildAt(i);
final int offset = ((int) next.getY()) - (headerHeight + getHeader(parent, adapterPosHere).itemView.getHeight());
if (offset < 0) {
return offset;
} else {
break;
}
}
}
}
top = Math.max(0, top);
}
return top;
}
示例12: onDependentViewChanged
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, CardView child, View dependency) {
initValues(child);
child.setY(dependency.getY() - child.getHeight() / 2);
if (notFirstRun) {
currentPos = dependency.getY();
if (currentPos > hidingPos)
animateIn(child);
else animateOut(child);
} else {
child.setX(shownPosX);
notFirstRun = true;
}
return false;
}
示例13: updateChild
import android.view.View; //导入方法依赖的package包/类
@Override
public void updateChild(View child, WearableRecyclerView parent) {
super.updateChild(child, parent);
// Figure out % progress from top to bottom
float centerOffset = ((float) child.getHeight() / 2.0f) / (float) recycler.getHeight();
float yRelativeToCenterOffset = (child.getY() / recycler.getHeight()) + centerOffset;
// Normalize for center
float progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset) * 2;
progressToCenter = Math.min(0.8f, progressToCenter);
child.setAlpha(1 - progressToCenter);
}
示例14: deleteItemInTheFirstLine_ItemHasMaximumHeight_SameStartPadding
import android.view.View; //导入方法依赖的package包/类
@Test
public void deleteItemInTheFirstLine_ItemHasMaximumHeight_SameStartPadding() throws Exception {
//arrange
//just adapt input items list to required start values
items.remove(1);
activity.runOnUiThread(() -> activity.initialize());
ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
InstrumentalUtil.waitForIdle();
View second = layoutManager.getChildAt(1);
int startHeight = second.getHeight();
double expectedY = second.getY();
//act
recyclerView.perform(
actionDelegate(((uiController, view) -> items.remove(1))),
notifyItemRemovedAction(1));
InstrumentalUtil.waitForIdle();
second = layoutManager.getChildAt(1);
int endHeight = second.getHeight();
double resultY = second.getY();
//assert
//check test behaviour
assumeTrue(startHeight > endHeight);
assertNotEquals(0, expectedY, 0.01);
assertNotEquals(0, resultY, 0.01);
assertEquals(resultY, expectedY, 0.01);
}
示例15: findListChildUnder
import android.view.View; //导入方法依赖的package包/类
private View findListChildUnder(float x, float y) {
View v = findChildUnder(x, y);
while (v != null) {
x -= v.getX();
y -= v.getY();
if (v instanceof RecyclerView/*AbsListView*/) {
// One more after this.
return findChildUnder((ViewGroup) v, x, y);
}
v = v instanceof ViewGroup ? findChildUnder((ViewGroup) v, x, y) : null;
}
return null;
}