本文整理匯總了Java中android.support.v4.view.ViewCompat.getY方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewCompat.getY方法的具體用法?Java ViewCompat.getY怎麽用?Java ViewCompat.getY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.getY方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onLayout
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mYDisplayed == -1) {
mYDisplayed = ViewCompat.getY(this);
}
}
示例2: followScrollToolbarLayout
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
* 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);
}
示例3: getY
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public static float getY(final @NonNull View v) {
if (VERSION.SDK_INT >= 11) {
return ViewCompat.getY(v);
} else {
return ((ViewGroup.MarginLayoutParams)v.getLayoutParams()).topMargin;
}
}
示例4: getChildY
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
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);
}
}
示例5: centerY
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public static float centerY(View view) {
return ViewCompat.getY(view) + view.getHeight() / 2f;
}