下面列出了android.widget.LinearLayout#getY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean onLayoutChild(CoordinatorLayout parent, LinearLayout child, int layoutDirection) {
parent.onLayoutChild(child, layoutDirection);
if (isFirst) {
isFirst = false;
if (oLy == 0) {
oLy = child.getY() + child.getHeight();
}
for (int i = 0; i < parent.getChildCount(); i++) {
View view = parent.getChildAt(i);
if (view instanceof AppBarLayout) {
height = view.getMeasuredHeight();
break;
}
}
child.setY(oLy);
}
return true;
}
@Override
public boolean onLayoutChild(CoordinatorLayout parent, LinearLayout child, int layoutDirection) {
parent.onLayoutChild(child, layoutDirection);
if (isFirst) {
isFirst = false;
if (oLy == 0) {
oLy = child.getY() + child.getHeight();
}
for (int i = 0; i < parent.getChildCount(); i++) {
View view = parent.getChildAt(i);
if (view instanceof AppBarLayout) {
height = view.getMeasuredHeight();
break;
}
}
child.setY(oLy);
}
return true;
}