When i do :
LayoutParams lp = getLayoutParams(view);
lp.x = absoluteX;
lp.y = absoluteY;
this.mWindowManager.updateViewLayout(view, lp);
Then i have one linear animation from the position where the view is to the new position absoluteX/absoluteY. how to move the view without any animation ?
I try to set lp.windowAnimations = 0 but it's change nothing :( any idea how i can do ?
If it's not possible to avoid the animation, is their any way to know the actual position of the view? maybe i can make it invisible still the real position is not absoluteX/absoluteY
NOTE:
looking the source code of android, i saw in the file WindowManager.java this entry :
/**
* Never animate position changes of the window.
*
* {@hide} */
public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040;
/**
* Control flags that are private to the platform.
* @hide
*/
public int privateFlags;
it's look like to be what i need, but i don't know how to access and set such flag :( any idea ?
try to disable the layout animation:
android:animateLayoutChanges="false"
val lp = WindowManager.LayoutParams(
width,
height,
this.windowManagerType(),
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
or WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSPARENT
)
val className = "android.view.WindowManager\$LayoutParams"
try {
val layoutParamsClass = Class.forName(className)
val privateFlags = layoutParamsClass.getField("privateFlags")
val noAnim = layoutParamsClass.getField("PRIVATE_FLAG_NO_MOVE_ANIMATION")
var privateFlagsValue = privateFlags.getInt(lp)
val noAnimFlag = noAnim.getInt(lp)
privateFlagsValue = privateFlagsValue or noAnimFlag
privateFlags.setInt(lp, privateFlagsValue)
} catch (e: Exception) {
Log.e("EXCEPT", "EXCEPTION: ${e.localizedMessage}")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With