如何在设置View的alpha之前创建1秒的延迟?

发布于 2024-12-20 02:36:53 字数 296 浏览 4 评论 0原文

在我的应用程序中,我将在一个动画之后设置 alpha。 就像:

hideMenu = AnimationUtils.loadAnimation( getApplication(), R.anim.menu_layout_hide);
 menuLayout.startAnimation(hideMenu);
 menuLayout.setVisibility(View.GONE);

但我想在 Alpha 设置视图之前设置 1 秒的延迟。因此,我无法看到该布局的动画。那么怎么可能呢?

谢谢。

In My Application i am going to set the alpha after one animation.
As like:

hideMenu = AnimationUtils.loadAnimation( getApplication(), R.anim.menu_layout_hide);
 menuLayout.startAnimation(hideMenu);
 menuLayout.setVisibility(View.GONE);

But i want to set the delay of 1 Sec before the Alpha set th the View. as Because of that i am not able to see the Animation of that layout. So How it is possibe ?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

蓝天 2024-12-27 02:36:53

在动画 xml 文件中,您可以使用 android:startOffset 属性:

android:startOffset int. The amount of milliseconds the animation delays after start() is called.

In your animation xml file you can use android:startOffset attribute:

android:startOffset int. The amount of milliseconds the animation delays after start() is called.
入怼 2024-12-27 02:36:53

你不能使用

android:startOffset int。动画的毫秒数
调用 start() 后的延迟。

在你的动画xml中?

请参阅动画资源文档

Can't you use the

android:startOffset int. The amount of milliseconds the animation
delays after start() is called.

in your animation xml?

See the animation resource documentation.

扶醉桌前 2024-12-27 02:36:53

假设您使用的是 view .animate() 方法,您可以设置起始偏移量:

view.animate().x(100)
              .setDuration(5000)
              .setStartDelay(1000);

Suppose you are using the view .animate() method, you can set the start offset:

view.animate().x(100)
              .setDuration(5000)
              .setStartDelay(1000);
街角卖回忆 2024-12-27 02:36:53

Handler 是实现这一目标的好技术。

new Handler().postDelayed(new Runnable()
{
   @Override
   public void run()
   {
     view.startAnimation(animation);
   }
}, 1000);

Handler is a good technique to achieve this.

new Handler().postDelayed(new Runnable()
{
   @Override
   public void run()
   {
     view.startAnimation(animation);
   }
}, 1000);
好多鱼好多余 2024-12-27 02:36:53

在您的情况下,您可以简单地这样做

hideMenu = AnimationUtils.loadAnimation( getApplication(), R.anim.menu_layout_hide);

hideMenu.setStartOffset(1000);

 menuLayout.startAnimation(hideMenu);
 menuLayout.setVisibility(View.GONE);

在这种情况下,您可以动态控制活动的开始时间值

In your case you can simply do like this

hideMenu = AnimationUtils.loadAnimation( getApplication(), R.anim.menu_layout_hide);

hideMenu.setStartOffset(1000);

 menuLayout.startAnimation(hideMenu);
 menuLayout.setVisibility(View.GONE);

In this case you can control dynamically value of the start time from the activity

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文