mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-20 08:39:55 +08:00
am 48c51e59: am 7ae9fe16: am 624e90dc: am b1a51676: Fix offset calculation math
* commit '48c51e594853c0f5a840dc6b75690b2af9d48dec': Fix offset calculation math GitOrigin-RevId=ba8b85a4ef455d64bb2cf640c47bc47eac657347 PiperOrigin-RevId: 140548657
This commit is contained in:
parent
e3ab398a87
commit
ba415acdc2
@ -16,9 +16,9 @@
|
||||
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.os.Build;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
|
||||
/**
|
||||
* Utility helper for moving a {@link android.view.View} around using
|
||||
@ -51,15 +51,15 @@ class ViewOffsetHelper {
|
||||
}
|
||||
|
||||
private void updateOffsets() {
|
||||
if (Build.VERSION.SDK_INT == 22) {
|
||||
// FIXME When running on L MR1, we have a problem with view's which are offset off
|
||||
// screen then back on. Using translationX/Y fixes it for now.
|
||||
ViewCompat.setTranslationY(mView, mOffsetTop);
|
||||
ViewCompat.setTranslationX(mView, mOffsetLeft);
|
||||
} else {
|
||||
// Else we can use the offset position methods
|
||||
ViewCompat.offsetTopAndBottom(mView, mOffsetTop - mView.getTop() - mLayoutTop);
|
||||
ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - mView.getLeft() - mLayoutLeft);
|
||||
if (mOffsetLeft != 0 || mOffsetTop != 0) {
|
||||
ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
|
||||
ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));
|
||||
|
||||
// Manually invalidate the parent to make sure we get drawn
|
||||
ViewParent parent = mView.getParent();
|
||||
if (parent instanceof View) {
|
||||
((View) parent).invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user