0

我想创建一个应用程序,我需要在单击时自定义按钮,旋转并从其后面显示图像..请注意,我是初学者,所以不要使用非常技术性的语言..

提前致谢

[编辑]请告诉我应该如何设计xml ..直到现在我已经创建了一个自定义按钮..所以我应该在它后面还是前面制作一个图像视图..

[添加代码]

button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
RotateAnimation rotate = new RotateAnimation(0,90);
rotate.setFillAfter(true);
button1.startAnimation(rotate);

AlphaAnimation alpha = new AlphaAnimation(0,1);
alpha.setFillAfter(true);
image.startAnimation(alpha);
}});

image.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
AlphaAnimation alpha = new AlphaAnimation(1,0);
alpha.setFillAfter(true);
image.startAnimation(alpha);

RotateAnimation rotate = new RotateAnimation(90,0);
rotate.setFillAfter(true);
button1.startAnimation(rotate);
}});
4

1 回答 1

0

在不使用技术语言的情况下,您将需要加载动画或仅在按钮的 OnClickListener 上实例化一个动画,并将图像 alpha 从 0 更改为 1。

RotateAnimation rotate = new RotateAnimation(0,90);
rotate.setFillAfter(true);
RotateAnimation rotateBack = new RotateAnimation(90,0);
rotateBack.setFillAfter(true);
AlphaAnimation alphaShow = new AlphaAnimation(0,1);
alpha.setFillAfter(true);
AlphaAnimation alphaHide = new AlphaAnimation(1,0);
alpha.setFillAfter(true);  

button.onClick = {
   button.startAnimation(rotate);
   image.startAnimation(alphaShow);
}

image.onClick = {
   image.startAnimation(alphaHide);
   button.startAnimation(rotateBack);
}
于 2013-06-12T03:27:40.043 回答