android-animation 相关问题

动画可以通过Java和XML集成到Android应用程序中。

Jetpack Compose - 一次性彩色动画

我需要在 Jetpack 中创建以下动画: 文本通常是灰色的,当发生某些事件(假设消息到达)时,文本会变成绿色并慢慢淡出回到灰色。 我用

回答 1 投票 0

如何在“组合多段路径”中制作动画

假设我有一个包含多个段的路径(moveTo 和 lineTo)。 如何使用 Compose 为该路径的绘制添加动画效果?

回答 1 投票 0

Kotlin 在片段之间设置 RecyclerView Item 的特定动画

我正在使用导航库来导航和制作动画。当我进行转换时,我的代码是这样的; 私人 val onClicked = 对象 :MyAdapter.OnItemClickListener{ 覆盖 fun onClicked(id: Int)...

回答 1 投票 0

AnimatedSplashScreen PageTransitionType 错误

我在使用 AnimatedSplashScreen 时遇到问题,在我添加 pageTransitionType 时一切正常。然后我得到一个错误: 构建 AnimatedBuilder(anima...

回答 6 投票 0

AnimationSet 未按预期执行顺序动画

如果我手动执行多个连续动画。它按预期工作。这是我的可行代码 扩展.xml 如果我手动执行多个连续动画。它按预期工作。这是我的可行代码 scale_up.xml <?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1.0" android:fromYScale="1.0" android:toXScale="1.1" android:toYScale="1.1" android:pivotX="50%" android:pivotY="50%" android:fillAfter="true" android:interpolator="@android:anim/decelerate_interpolator" android:duration="@android:integer/config_shortAnimTime" /> scale_down.xml <?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1.1" android:fromYScale="1.1" android:toXScale="1.0" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:fillAfter="true" android:interpolator="@android:anim/decelerate_interpolator" android:duration="@android:integer/config_shortAnimTime" /> 手动执行连续动画 public void startAnimation(Button button) { // Define the scale up animation Animation scaleUpAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_up); // Define the scale down animation Animation scaleDownAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_down); scaleUpAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { button.startAnimation(scaleDownAnimation); } @Override public void onAnimationRepeat(Animation animation) { } }); button.startAnimation(scaleUpAnimation); } 结果 但是,如果我尝试使用 AnimationSet 替换上述代码,动画结果就会损坏。 public void startAnimation(Button button) { // Define the scale up animation Animation scaleUpAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_up); // Define the scale down animation Animation scaleDownAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_down); // Create an AnimationSet to combine both animations // (It makes no difference whether I am using true or false) AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(scaleUpAnimation); animationSet.addAnimation(scaleDownAnimation); // Apply the animation to the button button.startAnimation(animationSet); } 使用AnimationSet的结果(动画不流畅) 我可以知道为什么AnimationSet不起作用吗?谢谢。 我们需要使用setStartOffset来延迟第二个动画的执行。这是解决上述问题的完整代码片段。 public void startAnimation(Button button) { int config_shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); // Define the scale up animation ScaleAnimation scaleUpAnimation = new ScaleAnimation( 1f, 1.02f, 1f, 1.02f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f ); scaleUpAnimation.setInterpolator(new DecelerateInterpolator()); scaleUpAnimation.setDuration(config_shortAnimTime); scaleUpAnimation.setFillAfter(true); // Define the scale down animation ScaleAnimation scaleDownAnimation = new ScaleAnimation( 1.02f, 1f, 1.02f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f ); scaleDownAnimation.setInterpolator(new AccelerateInterpolator()); scaleDownAnimation.setDuration(config_shortAnimTime); scaleDownAnimation.setFillAfter(true); scaleDownAnimation.setStartOffset(scaleUpAnimation.getDuration()); // Create an AnimationSet to combine both animations AnimationSet animationSet = new AnimationSet(false); animationSet.addAnimation(scaleUpAnimation); animationSet.addAnimation(scaleDownAnimation); // Apply the animation to the button button.startAnimation(animationSet); }

回答 1 投票 0

如何在AnimatorSet playSequentially()中添加动画之间的延迟?

我正在使用 AnimatorSet playSequentially 方法,如下所示: AnimatorSet set = new AnimatorSet(); ObjectAnimator in = ObjectAnimator.ofFloat(splash, "alpha", 0f, 1f); in.setDuration(2500); 在.

回答 3 投票 0

如何使用对象动画器设置 RecyclerView 中项目的背景颜色?

我有一个 RecyclerView,其中某些项目出现在屏幕上时,其背景颜色应以动画方式从粉色变为透明,持续 6 秒。 但问题是除此之外...

回答 1 投票 0

如何使用 Jetpack Compose 在 Android 中通过 Motion Layout 实现折叠标题?

我很好奇,并尝试实现类似 Playstore 的 UI,当我尝试使用搜索栏实现折叠标题时,我无法获得我在 Jetpack compose 中寻找的确切代码或文档。

回答 1 投票 0

何时初始化要在 Compose Canvas 中使用的资源?

我正在使用 Jetpack Compose,我想创建一个具有自定义阴影/渐变效果的圆圈。据我所知,无法在 DrawScope 内使用可组合对象创建它,我必须......

回答 2 投票 0

如何在没有动画的情况下更新RecyclerView项目?

我有一个RecyclerView。当我单击 RecyclerView 中某个项目内的按钮时,我想更改该项目中视图的颜色。以下是我的代码并且运行良好。但是,问题是我...

回答 6 投票 0

对象动画师剪辑视图组

我正在通过将 Y 方向上的视图组从其原始位置平移到顶部来创建动画。 我在 Android 13 中遇到一个奇怪的问题。移动

回答 1 投票 0

animateValueAsState 补间崩溃(AnimationVector 不能包含 NaN)

无法在本地重现,在 firebase 上看到多次崩溃。它似乎对不同设备和 Android 版本的不同用户产生一致的影响。 堆栈跟踪没有给出任何信息

回答 2 投票 0

如何将加载过程从 0 动画到 100?

启动画面上需要有一个视图。 即加载并以动画的形式显示加载从0%到100%。 我正在尝试按照以下方式进行操作,但是这种方法...

回答 2 投票 0

Jetpack Compose 动画性能问题

我是 Jetpack Compose 的新手,我尝试在点击菜单按钮时用动画旋转主屏幕。运行3-5次都正常,但是突然就疯狂滞后,我不知道为什么?是...

回答 2 投票 0

是否可以使可组合项在活动启动时出现动画?

我想让 UI 的某些部分在 Activity 启动时以动画形式出现。例如,如果我的 Activity 的 onCreate 如下所示: 覆盖 fun onCreate(savedInstanceState: Bundle?) { ...

回答 2 投票 0

如何使用 LazyColumn 的 animateItemPlacement() 而不在更改时自动滚动?

我在类似清单的样式中使用LazyColumn。该列表首先显示所有待完成的项目,最后显示所有已完成的项目。点击一个项目可以切换它是否完成。 这是我正在做的 MWE:

回答 2 投票 0

在用户滚动时更改视图的位置

我有一个长屏幕,我使用 NestedScrollView 和 RecyclerView ,如下图所示: 正如你所看到的,我在屏幕底部有一个 commentConatiner 布局,当前用户看到我...

回答 1 投票 0

Jetpack Compose - 状态变化时动画重组

我在状态更改时为可组合项设置动画时遇到问题。 我有一个可组合项,它接收 Interval (自定义类)和 List 类型的对象。这些是在整个过程中动态生成的...

回答 1 投票 0

如何使用带有共享元素转换的片段返回堆栈

共享元素转换替换了片段,因此我无法将其添加到后退堆栈并在按下后退箭头按钮时调用 popbackstack。 我有一个主要活动,里面有一个主要片段。那个...

回答 2 投票 0

如何用动画改变NumberPicker的值?

我创建了一个Android应用程序,其中有一个NumberPicker。我需要更改此 NumberPicker 的值,但要具有平滑的动画,就像您触摸它并更改其值时一样......

回答 6 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.