gpt4 book ai didi

java - 动画结束后滚动,android

转载 作者:太空狗 更新时间:2023-10-29 12:56:21 25 4
gpt4 key购买 nike

我有一系列的观点,电影院的座位。我需要对它们应用一组动画(缩放和平移)以进行某种缩放。我将动画应用于每个 View 。动画看起来像这样:

    AnimationSet set = new AnimationSet(context, null);

float toXDelta = (place.getX() * 2) - place.getX();
float toYDelta = (place.getY() * 2) - place.getY();
Animation translate = new TranslateAnimation(0, toXDelta, 0, toYDelta);
translate.setDuration(4000);
translate.setFillAfter(true);
translate.setFillEnabled(true);

Animation scale = new ScaleAnimation(1, 5, 1, 5);
scale.setDuration(4000);
scale.setFillAfter(true);
scale.setFillEnabled(true);

set.addAnimation(translate);
set.addAnimation(scale);

set.setFillAfter(true);
set.setAnimationListener(new KaroAnimationListener(this));

animation = set;

所以,我的布局看起来像这样:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_width="fill_parent"
android:padding="10px">
<ScrollView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0"
android:id="@+id/vertical_scroll"
android:fillViewport="true">
<HorizontalScrollView
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="@+id/scroll_view"
android:layout_width="wrap_content">
<RelativeLayout android:id="@+id/scrollable_places"
android:layout_height="wrap_content"
android:layout_width="wrap_content">

</RelativeLayout>
</HorizontalScrollView>
</ScrollView>

<Button android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/reserve_places_button"
android:onClick="onReserveClick"
android:layout_below="@id/vertical_scroll"
android:layout_weight="1"
android:text="Bron!"/>

我将我的 View 放入 ID 为 scrollable_placesRelativeLayout 中。因此,在动画结束后,一些 View 超出了屏幕范围,但没有滚动可用。我想我需要重新定义 RelativeLayout 或其他父级布局dimentions,但我不知道如何手动进行。谢谢!

最佳答案

您可以像这样尝试将滚动延迟发布到您的 ScrollView 的这一端:

scrollView.postDelayed( new Runnable() {
@Override
public void run() {
scrollView.fullScroll( View.FOCUS_DOWN);
}
}, 4300);

这样它适合在动画结束后开始,或者您可以在使用 AnimationListener 收听动画结束后执行此操作在这种情况下,您可以使用小于 4300 毫秒的延迟,大约 300 毫秒就可以了。

问候, 斯蒂芬

关于java - 动画结束后滚动,android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6409294/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com