美好的一天,大家!
今天,我想,我有一个非常有趣的问题。 在我的工作中,我们正在创建一个约会服务,其中一个主要功能将是屏幕,其中显示不同女孩(或男人)的照片,用户按“热”或“不”按钮。这两个按钮都显示在屏幕上的照片下方。 我们的分析说(上帝“祝福”他们......)我们应该实施某种“游戏”机制,所以想要这样的事情:当用户按下时,例如,“不”按钮 - 它开始冻结和覆盖冰,然后它打破,然后显示下一张照片。这不是缩放或旋转或翻译动画......按钮本身,其“加盖”的内容应该在一段很短的时间内改变(可能是一两秒钟)。 这让我很害怕,因为我正在考虑在不同的设备上缩放这些按钮,以及我正在制作的9件式和手工制作动画的不同麻烦 - 我想哭...
请告诉我,我需要你的专长 - 是不是真的要做这样的事情?或者也许有任何类型的变通办法......
拜托,我几乎要恐慌......
答案 0 :(得分:3)
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true"> <item android:drawable="@drawable/rocket_thrust1" android:duration="200" /> <item android:drawable="@drawable/rocket_thrust2" android:duration="200" /> <item android:drawable="@drawable/rocket_thrust3" android:duration="200" /> </animation-list>
然后
AnimationDrawable rocketAnimation;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
rocketImage.setBackgroundResource(R.drawable.rocket_thrust);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
}
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
rocketAnimation.start();
return true;
}
return super.onTouchEvent(event);
}
答案 1 :(得分:2)
在可绘制文件夹中创建图像列表:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loading"
android:oneshot="false" >
<item android:drawable="@drawable/preloader_01" android:duration="50" />
<item android:drawable="@drawable/preloader_02" android:duration="50" />
<item android:drawable="@drawable/preloader_03" android:duration="50" />
<item android:drawable="@drawable/preloader_04" android:duration="50" />
使用ImageView img代替按钮并将列表设置为xml中的背景,然后在代码中使用AnimationDrawable启动动画
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start();`
答案 2 :(得分:0)
您可以使用ObjectAnimators和ValueAnimators为Alpha,位置以及按钮的任何属性设置动画。
如果您想要自定义动画,例如冰效果,您必须自己制作。