質問編集履歴

2

コードの追加

2017/01/20 13:21

投稿

pomupomu
pomupomu

スコア15

test CHANGED
File without changes
test CHANGED
@@ -77,3 +77,21 @@
77
77
  }
78
78
 
79
79
  ```
80
+
81
+ ```java
82
+
83
+ TestView.java
84
+
85
+ @Override
86
+
87
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
88
+
89
+ int width = MeasureSpec.getSize(widthMeasureSpec);
90
+
91
+ int height = 5000;
92
+
93
+ setMeasuredDimension(width, height);
94
+
95
+ }
96
+
97
+ ```

1

コードの追加

2017/01/20 13:21

投稿

pomupomu
pomupomu

スコア15

test CHANGED
File without changes
test CHANGED
@@ -5,3 +5,75 @@
5
5
 
6
6
 
7
7
  参考になるサイトを教えていただく形でも構いません。ご回答よろしくお願いいたします。
8
+
9
+
10
+
11
+ ```java
12
+
13
+ MainActivity.java
14
+
15
+ public class MainActivity extends AppCompatActivity {
16
+
17
+
18
+
19
+ private TestView testView;
20
+
21
+
22
+
23
+ protected void onCreate(Bundle savedInstanceState) {
24
+
25
+ super.onCreate(savedInstanceState);
26
+
27
+ testView = new TestView(this);
28
+
29
+ setContentView(testView);
30
+
31
+ }
32
+
33
+
34
+
35
+ @Override
36
+
37
+ public void onResume() {
38
+
39
+ super.onResume();
40
+
41
+
42
+
43
+
44
+
45
+ timer = new Timer(false);
46
+
47
+ timer.schedule(new TimerTask() {
48
+
49
+ public void run() {
50
+
51
+ handler.post(new Runnable() {
52
+
53
+ public void run() {
54
+
55
+ // position移動
56
+
57
+ pos += 1;
58
+
59
+ testView.setPositon(pos);
60
+
61
+ if (pos >= 7){
62
+
63
+ pos =0;
64
+
65
+ }
66
+
67
+ testView.invalidate();
68
+
69
+ }
70
+
71
+ });
72
+
73
+ }
74
+
75
+ },0, period);
76
+
77
+ }
78
+
79
+ ```