安卓平台上有哪些图片视图过渡库?

3

我需要制作图片视图的转换效果,但是这对我来说相当困难。经过数小时的搜索,我只找到了一些活动转换和简单的淡入淡出转换的预构建库。

我找到的是与活动和ViewFlipper相关的材料动画:

https://github.com/lgvalle/Material-Animations https://androidmyway.wordpress.com/2012/10/30/slide-transition-in-viewflipper/

我需要垂直条形、溶解、爆炸等其他高级转换效果,就像Windows电影制作或jquery动画中的那样。

Car Dissolve transition

Car Vertical Bar transition

如果有任何预构建的Android库可以实现此类效果,请告诉我。谢谢!


https://android-arsenal.com/tag/6 - karan
@Karan Mer,感谢您提供的链接,但我在那里没有找到我需要的东西。 - dilz
如果您对此有任何想法或链接,请在评论中分享! - Mayur R. Amipara
@MayurR.Amipara 目前为止我还没有找到这样的转换,如果我找到了我会分享的。 - dilz
2个回答

1
  1. 从这里下载一组动画:

    ------> https://drive.google.com/folderview?id=0B_tCPatPrHgyWmNtWjM2X1ZiV1k&ddrp=1#

  2. 在您的Android项目中,如果使用Eclipse,请打开/res文件夹,然后转到菜单: 文件>新建>文件夹> 给文件夹命名为:"anim"。

  3. 将所有文件复制到此文件夹中。只需从Windows资源管理器中拖动它们即可。现在我们完成了准备工作,可以使用已下载的内容了。

  4. Activity主屏幕包含一个图像。当发生点击时,图像开始动画,参见下面的代码示例:

/*xml文件 *

*文件结束 */

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class MainActivity extends Activity {
ImageView image;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    image = (ImageView) findViewById(R.id.imageView);

    image.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View arg0) {

        image.startAnimation(selectanimation((int)(Math.random()*6))); //randomly select animation 0-5
      }

    });
}
  private Animation selectanimation(int index) {
    switch(index){
    /*
     * create animations, and return them to caller. 
     */
    case 0: return new AnimationUtils().loadAnimation(this, R.anim.shake);
    case 1: return new AnimationUtils().loadAnimation(this, R.anim.fade);
    case 2: return new AnimationUtils().loadAnimation(this, R.anim.slide_left);
    case 3: return new AnimationUtils().loadAnimation(this, R.anim.wave_scale);
    case 4: return new AnimationUtils().loadAnimation(this, R.anim.hold);
    case 5: return new AnimationUtils().loadAnimation(this, R.anim.zoom_enter);
    }
    return null;
  }
}

在这里下载完整的源代码


谢谢你的回答,我浏览了所有这些动画,但是我没有找到我想要的东西。 - dilz
@AndroidEnthusiastic,dilz还提供了他想要的样本图像,他寻找的是类似于http://javagraphics.blogspot.in/2007/04/slideshows-transitions-swf.html的效果。 - Mayur R. Amipara

1

你应该尝试使用Android动画类编写自己的自定义动画。这是一个库链接,你可以根据需要进行学习和修改。它包含了像爆炸、折叠等动画。

https://github.com/2359media/EasyAndroidAnimations

对于你的问题,第一个动画有点难。它需要遮罩才能实现像上面展示的完美动画。如果你想要一些简单的提示,可以尝试使用两张黑色的图片,如下所示。确保用黑色部分覆盖整个屏幕。然后将一张图像向下移动,另一张向右移动以创建效果。

horizontal bar

vertical bar

第二个动画非常简单,您可以尝试以下提示中的内容:
<framelayout>
     <imageview src="@drawable/car.jpg">
     <linearlayout 
         weightsum="9" 
         orientation="horizontal"><!--set it's width height to cover car image-->
        <imageview @+id="imgview1" 
           weight="1" src="@drawable/blackbar.jpg">
        <imageview @+id="imgview2"
           weight="1" src="@drawable/blackbar.jpg">
        .
        .
        <imageview @+id="imgview9"
           weight="1" src="drawable/blackbar.jpg">
     </linearlayout>
</framelayout>

在您的Java代码中,尝试使用以下动画效果来显示黑色条纹。
 new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    ScaleAnimation anim = new ScaleAnimation(1.0f, 0.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,0.0f, Animation.RELATIVE_TO_SELF, 0.5f);
                    anim.setFillAfter(true);
                    anim.setDuration(400);
                    imgBlackBar1.startAnimation(anim);

                }
            });
        }
    }, 150);

现在,根据您的需求,为bar2设置300ms的延迟,为bar3设置450ms的延迟等等。

对于第二个动画,你的解决方案真的对我很有帮助,非常感谢。 - dilz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接