質問編集履歴

1

コードの追加

2018/02/22 14:43

投稿

yuba_yuba
yuba_yuba

スコア44

test CHANGED
File without changes
test CHANGED
@@ -11,3 +11,83 @@
11
11
  アニメーションするビューは同じものを使いたいです
12
12
 
13
13
  このような実装はできるでしょうか?
14
+
15
+
16
+
17
+ 追記:以下がコードになります
18
+
19
+
20
+
21
+ ```java
22
+
23
+ import android.support.v7.app.AppCompatActivity;
24
+
25
+ import android.os.Bundle;
26
+
27
+ import android.view.View;
28
+
29
+ import android.view.animation.Animation;
30
+
31
+ import android.view.animation.TranslateAnimation;
32
+
33
+ import android.widget.Button;
34
+
35
+ import android.widget.ImageView;
36
+
37
+
38
+
39
+ public class MainActivity extends AppCompatActivity {
40
+
41
+
42
+
43
+ private TranslateAnimation translateAnimation;
44
+
45
+
46
+
47
+ @Override
48
+
49
+ protected void onCreate(Bundle savedInstanceState) {
50
+
51
+ super.onCreate(savedInstanceState);
52
+
53
+ setContentView(R.layout.activity_main);
54
+
55
+
56
+
57
+ Button button=findViewById(R.id.button);
58
+
59
+
60
+
61
+ button.setOnClickListener(new View.OnClickListener() {
62
+
63
+ @Override
64
+
65
+ public void onClick(View view) {
66
+
67
+ ImageView imageView=findViewById(R.id.imageView);
68
+
69
+ translateAnimation = new TranslateAnimation(
70
+
71
+ Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 350.0f,
72
+
73
+ Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);
74
+
75
+
76
+
77
+ translateAnimation.setDuration(2000);
78
+
79
+ imageView.startAnimation(translateAnimation);
80
+
81
+ }
82
+
83
+ });
84
+
85
+
86
+
87
+
88
+
89
+ }
90
+
91
+ }
92
+
93
+ ```