回答編集履歴
1
修正
test
CHANGED
@@ -17,3 +17,119 @@
|
|
17
17
|
```
|
18
18
|
|
19
19
|
ただし、MyViewでonMeasure()を呼んで高さを設定しないといけませんが
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
~~~
|
24
|
+
|
25
|
+
このような感じでしょう
|
26
|
+
|
27
|
+
![イメージ説明](2616668bc295d1f798054070f6ce488b.gif)
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
以下がコードです、タイマーは不完全なのとここでは主題ではないので省いています
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
MainActivity.java
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
public class MainActivity extends AppCompatActivity {
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
private TestView testView;
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
@Override
|
50
|
+
|
51
|
+
protected void onCreate(Bundle savedInstanceState) {
|
52
|
+
|
53
|
+
super.onCreate(savedInstanceState);
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
testView = new TestView(this);
|
58
|
+
|
59
|
+
ScrollView scrollView = new ScrollView(this);
|
60
|
+
|
61
|
+
scrollView.addView(testView);
|
62
|
+
|
63
|
+
setContentView(scrollView);
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
TestView.java
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
public class TestView extends View {
|
78
|
+
|
79
|
+
Bitmap bmp;
|
80
|
+
|
81
|
+
private Paint paint = new Paint();
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
public TestView(Context context) {
|
86
|
+
|
87
|
+
super(context);
|
88
|
+
|
89
|
+
bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
@Override
|
96
|
+
|
97
|
+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
98
|
+
|
99
|
+
int width = MeasureSpec.getSize(widthMeasureSpec);
|
100
|
+
|
101
|
+
int height = 10000;
|
102
|
+
|
103
|
+
setMeasuredDimension(width, height);
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
public void onDraw(Canvas canvas) {
|
110
|
+
|
111
|
+
canvas.drawBitmap(bmp, 200, 500, paint);
|
112
|
+
|
113
|
+
canvas.drawBitmap(bmp, 500, 800, paint);
|
114
|
+
|
115
|
+
canvas.drawBitmap(bmp, 800, 1500, paint);
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
コピペと質問を繰り返すのはそろそろ止めて
|
126
|
+
|
127
|
+
自力で解決、自力でサイト情報を取り込めるように
|
128
|
+
|
129
|
+
基礎から勉強したほうがいいのではないでしょうか?
|
130
|
+
|
131
|
+
スクールとか、誰か分かっている人から直接教えてもらった方がいいと思います
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|