質問編集履歴

1

コードの変更

2016/05/22 09:00

投稿

j4ck4ll
j4ck4ll

スコア11

test CHANGED
File without changes
test CHANGED
@@ -126,6 +126,100 @@
126
126
 
127
127
  ```
128
128
 
129
+ ```java
130
+
131
+ public class Draw extends View {
132
+
133
+ private Paint paint;
134
+
135
+ float x=300;
136
+
137
+ float y=300;
138
+
139
+
140
+
141
+ public Draw(Context context, AttributeSet attr) {
142
+
143
+ super(context,attr);
144
+
145
+ paint = new Paint();
146
+
147
+ }
148
+
149
+
150
+
151
+ @Override
152
+
153
+ public boolean onTouchEvent(MotionEvent e){
154
+
155
+ if(e.getAction() == MotionEvent.ACTION_DOWN){
156
+
157
+ x=e.getX();
158
+
159
+ y=e.getY();
160
+
161
+ }
162
+
163
+
164
+
165
+ if(e.getAction() == MotionEvent.ACTION_MOVE){
166
+
167
+ x=e.getX();
168
+
169
+ y=e.getY();
170
+
171
+ }
172
+
173
+ invalidate();
174
+
175
+ return true;
176
+
177
+ }
178
+
179
+ @Override
180
+
181
+ protected void onDraw(Canvas canvas){
182
+
183
+ super.onDraw(canvas);
184
+
185
+ canvas.drawCircle(x,y,100,paint);
186
+
187
+ }
188
+
189
+ }
190
+
191
+ ```
192
+
193
+
194
+
195
+ ```xml
196
+
197
+ <LinearLayout
198
+
199
+ xmlns:android="http://schemas.android.com/apk/res/android"
200
+
201
+ android:layout_width="match_parent"
202
+
203
+ android:layout_height="match_parent"
204
+
205
+ android:orientation="vertical">
206
+
207
+
208
+
209
+
210
+
211
+ <com.example.user.sample.Draw
212
+
213
+ android:layout_width="match_parent"
214
+
215
+ android:layout_height="match_parent" />
216
+
217
+
218
+
219
+ </LinearLayout>
220
+
221
+ ```
222
+
129
223
  LayerServiceの
130
224
 
131
225
  // 重ね合わせするViewの設定を行う