Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在设置视图的alpha之前创建1秒的延迟?_Android_Xml_Animation_Android Animation_Layout Animation - Fatal编程技术网

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

Android 如何在设置视图的alpha之前创建1秒的延迟?,android,xml,animation,android-animation,layout-animation,Android,Xml,Animation,Android Animation,Layout Animation,在我的应用程序中,我将在一个动画之后设置alpha。 如下所示: 但是我想在Alpha设置视图之前设置1秒的延迟。正因为如此,我无法看到该布局的动画。那么这怎么可能呢 谢谢。在动画xml文件中,您可以使用android:startOffset属性: android:startOffset int. The amount of milliseconds the animation delays after start() is called. 你不能用这个吗 android:startOffse

在我的应用程序中,我将在一个动画之后设置alpha。 如下所示:

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


谢谢。

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

android:startOffset int. The amount of milliseconds the animation delays after start() is called.
你不能用这个吗

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

在动画xml中


请参见。

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

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

处理程序是实现这一点的一种好技术

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

在你的情况下,你可以这样做

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

hideMenu.setStartOffset(1000);

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

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

谢谢您的回复。让我试试。如果你不介意的话,在动画中后期延迟是没有意义的,因为动画本身就有setStartDelay方法。请不要把我的话当作冒犯,但我告诉你我的感受。
hideMenu = AnimationUtils.loadAnimation( getApplication(), R.anim.menu_layout_hide);

hideMenu.setStartOffset(1000);

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