再会,
我正在尝试实现一个从下方Animation滑入我的屏幕的。WebView这是我的动画 xml 文件的代码:
slide_in_from_bottom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<translate android:fromYDelta="100%" android:toYDelta="0%"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="700"/>
</set>
这是我要求我WebView滑入的地方:
Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in_from_bottom);
slideIn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Log.d("animation", "started");
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
webView.setVisibility(View.VISIBLE);
Log.d("animation", "stopped");
}
});
webView.startAnimation(slideIn);
这很好用,但问题是我WebView的大小并不总是相同。如果它很大,这会导致它非常快地滑入,WebView如果它很小,则(相对)缓慢。
我也尝试过使用ObjectAnimator:
ObjectAnimator moveInFromBottom = ObjectAnimator.ofFloat(webView,
"translationY", 900f, 0f);
moveInFromBottom.setDuration(700);
moveInFromBottom.start();
这很好用,但是有一个错误会从inputText我的WebView. (真的很奇怪,找不到任何关于它的信息)。然后我仍然可以在 中输入文本inputText,但我无法使用退格键删除它:S
所以,我的问题是:我怎样才能确保我Animation总是以相同的速度滑入,无论我的身高WebView是多少?