I did not have time to wait until the bounty expires, so I coded the bottom gap of the gap until I get a better solution. In case it helps someone else or gives them an idea for a decent answer, this is what I did. However, I suspect that it is ineffective, like all hell, since I assume that it forces the relay window of each frame of the animation, rather than just panning the bitmap across the screen. Of course, this is not all, but this is a critical bit:
// Not shown: setting currentVerticalMargin, targetVerticalMargin, or calling this method private synchronized void restartVerticalMarginAnimator() { if (verticalMarginAnimator != null) { return; } final Dialog dialog = this.getDialog(); if (dialog == null) { return; } final WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); verticalMarginAnimator = new TimeAnimator(); verticalMarginAnimator.setTimeListener(new TimeListener() { @Override public void onTimeUpdate(TimeAnimator a, long totalTime, long deltaTime) { float stretch = targetVerticalMargin - currentVerticalMargin; float distance = WINDOW_ANIMATION_SPEED * deltaTime / 1000L; boolean finished = false; // Adjust distance so it capped at "going all the way to target" and no further, // and has the right sign if we're animating upward. if (distance > Math.abs(stretch)) { distance = stretch; finished = true; } else if (stretch < 0) { distance *= -1f; } // Move. currentVerticalMargin += distance; if (finished) { verticalMarginAnimator.end(); verticalMarginAnimator = null; } params.verticalMargin = currentVerticalMargin; dialog.getWindow().setAttributes(params); } }); verticalMarginAnimator.start(); }
source share