This one's a little annoying. Android animates all window changes, and they've made the flag to disable it private. You can disable window animations using reflection
WindowManager.LayoutParams wp = new WindowManager.LayoutParams();
String className = "android.view.WindowManager$LayoutParams";
try {
Class layoutParamsClass = Class.forName(className);
Field privateFlags = layoutParamsClass.getField("privateFlags");
Field noAnim = layoutParamsClass.getField("PRIVATE_FLAG_NO_MOVE_ANIMATION");
int privateFlagsValue = privateFlags.getInt(wp);
int noAnimFlag = noAnim.getInt(wp);
privateFlagsValue |= noAnimFlag;
privateFlags.setInt(wp, privateFlagsValue);
// Dynamically do stuff with this class
// List constructors, fields, methods, etc.
} catch (ClassNotFoundException e) {
Logger.l.e(e.toString());
// Class not found!
} catch (Exception e) {
Logger.l.e(e.toString());
// Unknown exception
}
Now wp
will not animate layout changes. Note you'll probably see flicker when you change the window size. I haven't found a way to work around that yet.