公告
财富商城
积分规则
提问
发文
2019-03-07 04:06发布
来,给爷笑一个
I would like to take an Imageview that has a butterfly png and animate it so it looks like the butterfly is moving its wings.
How can I get this effect with an Android native animation ?
ImageView iView = (ImageView) findViewById(R.id.test_image); if (iView != null) Glide.with(this).load("http://i.imgur.com/1ALnB2s.gif").asGif().into(iView);
Detailed Example
// For a simple view: @Override public void onCreate(Bundle savedInstanceState) { ... ImageView imageView = (ImageView) findViewById(R.id.my_image_view); Glide.with(this).load("http://some image link").into(imageView); } // For a simple image list: @Override public View getView(int position, View recycled, ViewGroup container) { final ImageView myImageView; if (recycled == null) { myImageView = (ImageView) inflater.inflate(R.layout.my_image_view, container, false); } else { myImageView = (ImageView) recycled; } String url = myUrls.get(position); Glide .with(myFragment) .load(url) .centerCrop() .placeholder(R.drawable.loading_spinner) .crossFade() .into(myImageView); return myImageView; }
Output:
GitHub Link
Wiki Link
I've done that in iOS, so you need to scale it up and scale it down with a timer.
It worked, this is what I did, First I used Glide to load my img, then I created an animation like so:
final ScaleAnimation growanim = new ScaleAnimation(1.0f, randscale), 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f); growanim.setDuration(randomDuration); growanim.setRepeatCount(-1); growanim.setRepeatMode(Animation.REVERSE); growanim.setInterpolator(new AccelerateInterpolator()); img.setAnimation(growanim); growanim.start();
randomDuration = random.nextInt(2000 - 100 + 1) + 100l); --> random times. randscale = random.nextFloat()*0.5f)+0.3f);---> random scales.
Thank you all for your help.
最多设置5个标签!
Use Glide Simple Example:
Detailed Example
Output:
GitHub Link
Wiki Link
I've done that in iOS, so you need to scale it up and scale it down with a timer.
It worked, this is what I did, First I used Glide to load my img, then I created an animation like so:
randomDuration = random.nextInt(2000 - 100 + 1) + 100l); --> random times. randscale = random.nextFloat()*0.5f)+0.3f);---> random scales.
Thank you all for your help.