0
私は下のシートをスクロールするユーザーに基づいていくつかのビューのY位置をスムーズにアニメーションしたいと思います。ビューの翻訳をアニメーションにするYボトムシートのスクロール
アニメーションが少しぎくしゃくですが。
これは、ボトムシートをスクロールすると、ある間隔で私にslideOffsetが与えられます。これは、現在行っているようにsetTranlationYにはあまりにも少ないことです。
これを行うより良い方法はありますか?
ボトムシートコールバック
BottomSheetBehavior.BottomSheetCallback() {
@Override public void onSlide(@NonNull View bottomSheetView, float slideOffset) {
int offset = (int) (slideOffset * 100);
if (offset > 0) {
scrollingHeaderView.animate(offset);
}
}
});
scrollingHeaderView
public void animate(int offset) {
position = -(offset/2);
arrow.setTranslationY(offset * ANIMATION_RATIO_ARROW);
detailView.setTranslationY(offset * ANIMATION_RATIO);
}
私は各ステップで小さなアニメーションの多くを作成するためにObjectAnimatorを使用して試してみました。
ObjectAnimator.ofFloat(arrow, "translationY", arrow.getTranslationY(), position * ANIMATION_RATIO_ARROW).start();