Android的动画背景图片 [英] Android animate background image

查看:621
本文介绍了Android的动画背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相对布局,我已经设置它的背景,绘制,这是一个选择。

I have one Relative Layout and i have set it's background as drawable, which is a selector.

有总拖背景,这个相对布局,一个是国家作为选择,一个处于非选择的模式,这两种状态是在绘制选择xml文件来处理。

There are total tow background to this Relative Layout and one is in state as selected and one is in non selected mode, both the states are handled in the drawable selector xml file.

我想实现当选择不选择或反之亦然我想显示/输出动​​画淡入从选择切换背景图像。

What i want to implement is when selector switch the background image from selected to not selected or vice-versa i want to display fade in/out animation.

我发现我需要使用的android:exitFadeDuration =@安卓整数/ config_mediumAnimTime 在xml文件实现这一点,但我使用的Andr​​oid API级别8它不具有此特性。

I found out that i need to use android:exitFadeDuration="@android:integer/config_mediumAnimTime for implementing this in xml file but i am using Android API level 8 and it does not have this property.

那么,我需要在Java code来实现这一点,我应该如何在Java中实现这个?结果
有没有实现它在XML中任何其他的选择吗?

So do i need to implement this in java code, how should i implement this in java?
Is there any other option to implement it in xml?

感谢。

推荐答案

请使用下面的行会解决你的问题。

Please use the following line it will solve your problem.

checkBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

               @Override
               public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {


                    imageView1.setBackgroundResource(R.drawable.checkbox_normal);
                    Animation hyperspaceJump = AnimationUtils.loadAnimation(Test1Activity.this, R.anim.animation_big_to_small_rotate); 
                    imageView1.startAnimation(hyperspaceJump); 
                    imageView1.setVisibility(View.VISIBLE);


               }
            });

而不是 animation_big_to_small_rotate :使用您拥有动画XML文件。你可以改变图像作为你的愿望。

instead of animation_big_to_small_rotate use the xml file which you have for animation. and you can change the images as your wish.

这篇关于Android的动画背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆