回答編集履歴

5

追記

2020/12/20 14:09

投稿

razuma
razuma

スコア1313

test CHANGED
@@ -293,3 +293,125 @@
293
293
  ```
294
294
 
295
295
  が抜けています。私が書いた`activity_main.xml`を参照して入れてみてください。
296
+
297
+
298
+
299
+ ```
300
+
301
+ <?xml version="1.0" encoding="utf-8"?>
302
+
303
+ <androidx.constraintlayout.widget.ConstraintLayout
304
+
305
+ android:layout_height="match_parent"
306
+
307
+ android:layout_width="match_parent"
308
+
309
+ xmlns:android="http://schemas.android.com/apk/res/android"
310
+
311
+ xmlns:app="http://schemas.android.com/apk/res-auto"
312
+
313
+ xmlns:tools="http://schemas.android.com/tools">
314
+
315
+
316
+
317
+ <Button
318
+
319
+ android:id="@+id/choki"
320
+
321
+ android:layout_width="100dp"
322
+
323
+ android:layout_height="100dp"
324
+
325
+ android:layout_marginStart="8dp"
326
+
327
+ android:layout_marginTop="8dp"
328
+
329
+ android:layout_marginEnd="8dp"
330
+
331
+ android:layout_marginBottom="8dp"
332
+
333
+ android:scaleType="fitCenter"
334
+
335
+ app:layout_constraintBottom_toBottomOf="parent"
336
+
337
+ app:layout_constraintEnd_toEndOf="parent"
338
+
339
+ app:layout_constraintStart_toStartOf="parent"
340
+
341
+ app:layout_constraintTop_toTopOf="parent"
342
+
343
+ app:srcCompat="@drawable/choki" />
344
+
345
+
346
+
347
+ <ImageButton
348
+
349
+ android:id="@+id/pa"
350
+
351
+ android:layout_width="100dp"
352
+
353
+ android:layout_height="100dp"
354
+
355
+ android:layout_marginStart="8dp"
356
+
357
+ android:scaleType="fitCenter"
358
+
359
+ app:layout_constraintStart_toEndOf="@+id/choki"
360
+
361
+ app:layout_constraintTop_toTopOf="@+id/choki"
362
+
363
+ app:srcCompat="@drawable/pa" />
364
+
365
+
366
+
367
+ <ImageButton
368
+
369
+ android:id="@+id/gu"
370
+
371
+ android:layout_width="100dp"
372
+
373
+ android:layout_height="100dp"
374
+
375
+ android:layout_marginEnd="8dp"
376
+
377
+ android:scaleType="fitCenter"
378
+
379
+ app:layout_constraintEnd_toStartOf="@+id/choki"
380
+
381
+ app:layout_constraintTop_toTopOf="@+id/choki"
382
+
383
+ app:srcCompat="@drawable/gu" />
384
+
385
+
386
+
387
+ <TextView
388
+
389
+ android:id="@+id/textView"
390
+
391
+ android:layout_width="wrap_content"
392
+
393
+ android:layout_height="wrap_content"
394
+
395
+ android:layout_marginStart="8dp"
396
+
397
+ android:layout_marginTop="8dp"
398
+
399
+ android:layout_marginEnd="8dp"
400
+
401
+ android:layout_marginBottom="8dp"
402
+
403
+ android:text="@string/janken_text"
404
+
405
+ android:textAppearance="@style/TextAppearance.AppCompat.Large"
406
+
407
+ app:layout_constraintBottom_toTopOf="@+id/choki"
408
+
409
+ app:layout_constraintEnd_toEndOf="parent"
410
+
411
+ app:layout_constraintStart_toStartOf="parent"
412
+
413
+ app:layout_constraintTop_toTopOf="parent" />
414
+
415
+ </androidx.constraintlayout.widget.ConstraintLayout>
416
+
417
+ ```

4

回答追記

2020/12/20 14:09

投稿

razuma
razuma

スコア1313

test CHANGED
@@ -277,3 +277,19 @@
277
277
  }
278
278
 
279
279
  ```
280
+
281
+
282
+
283
+ ===追記
284
+
285
+ `activity_main.xml`の一番上の層の`ConstraintLayout`にて
286
+
287
+ ```
288
+
289
+ android:layout_width="match_parent"
290
+
291
+ android:layout_height="match_parent"
292
+
293
+ ```
294
+
295
+ が抜けています。私が書いた`activity_main.xml`を参照して入れてみてください。

3

追記

2020/12/20 14:07

投稿

razuma
razuma

スコア1313

test CHANGED
@@ -217,3 +217,63 @@
217
217
 
218
218
 
219
219
  以上、よろしくお願いいたします。
220
+
221
+
222
+
223
+ === 追記
224
+
225
+ 真っ白になるとのことですが、MainActivityが2重になって書かれているので1つ削除してください
226
+
227
+
228
+
229
+ ```
230
+
231
+ class MainActivity : AppCompatActivity() {
232
+
233
+
234
+
235
+ override fun onCreate(savedInstanceState: Bundle?) {
236
+
237
+ super.onCreate(savedInstanceState)
238
+
239
+ setContentView(R.layout.activity_main)
240
+
241
+
242
+
243
+ gu.setOnClickListener { onJankenButtonTapped(it) }
244
+
245
+ choki.setOnClickListener { onJankenButtonTapped(it) }
246
+
247
+ pa.setOnClickListener { onJankenButtonTapped(it) }
248
+
249
+
250
+
251
+ val pref = PreferenceManager.getDefaultSharedPreferences(this)
252
+
253
+ pref.edit {
254
+
255
+ clear()
256
+
257
+ }
258
+
259
+ }
260
+
261
+
262
+
263
+ fun onJankenButtonTapped(view: View1?) {
264
+
265
+ val streak = this.intent.getIntExtra("streak", 0)
266
+
267
+ val intent = Intent(this, ResultActivity::class.java)
268
+
269
+ intent.putExtra("MY_HAND", view?.id)
270
+
271
+ intent.putExtra("streak", streak)
272
+
273
+ startActivity(intent)
274
+
275
+ }
276
+
277
+ }
278
+
279
+ ```

2

追記

2020/12/20 11:27

投稿

razuma
razuma

スコア1313

test CHANGED
@@ -7,3 +7,213 @@
7
7
 
8
8
 
9
9
  ![イメージ説明](3d2d59b3d745708ff32dd645a3e495b1.png)
10
+
11
+
12
+
13
+ ===追記
14
+
15
+ activity_result.xmlにて`tools:layout_editor_absoluteX`や`tools:layout_editor_absoluteY`が使われています。
16
+
17
+ こちらはツール上ではレイアウトされているように見えますが実行した際には意味をなさない値です。
18
+
19
+ 表示上と同じように見えるように書き換えてみましたが以下にすることで問題は解決しないでしょうか。
20
+
21
+
22
+
23
+ ```
24
+
25
+ <?xml version="1.0" encoding="utf-8"?>
26
+
27
+ <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
28
+
29
+ xmlns:app="http://schemas.android.com/apk/res-auto"
30
+
31
+ xmlns:tools="http://schemas.android.com/tools"
32
+
33
+ android:layout_width="match_parent"
34
+
35
+ android:layout_height="match_parent"
36
+
37
+ tools:context=".ResultActivity">
38
+
39
+
40
+
41
+ <TextView
42
+
43
+ android:id="@+id/resultLabel"
44
+
45
+ android:layout_width="wrap_content"
46
+
47
+ android:layout_height="wrap_content"
48
+
49
+ android:layout_marginStart="8dp"
50
+
51
+ android:layout_marginTop="8dp"
52
+
53
+ android:layout_marginEnd="8dp"
54
+
55
+ android:layout_marginBottom="8dp"
56
+
57
+ android:text="TextView"
58
+
59
+ android:textAppearance="@style/TextAppearance.AppCompat.Large"
60
+
61
+ app:layout_constraintBottom_toBottomOf="parent"
62
+
63
+ app:layout_constraintEnd_toEndOf="parent"
64
+
65
+ app:layout_constraintStart_toStartOf="parent"
66
+
67
+ app:layout_constraintTop_toTopOf="parent" />
68
+
69
+
70
+
71
+ <ImageView
72
+
73
+ android:id="@+id/myHandImage"
74
+
75
+ android:layout_width="160dp"
76
+
77
+ android:layout_height="160dp"
78
+
79
+ android:layout_marginStart="8dp"
80
+
81
+ android:layout_marginTop="8dp"
82
+
83
+ android:layout_marginEnd="8dp"
84
+
85
+ android:layout_marginBottom="8dp"
86
+
87
+ android:scaleType="fitCenter"
88
+
89
+ app:layout_constraintBottom_toTopOf="@+id/resultLabel"
90
+
91
+ app:layout_constraintEnd_toEndOf="parent"
92
+
93
+ app:layout_constraintStart_toStartOf="parent"
94
+
95
+ app:layout_constraintTop_toTopOf="parent"
96
+
97
+ app:srcCompat="@drawable/gu" />
98
+
99
+
100
+
101
+ <ImageView
102
+
103
+ android:id="@+id/comHandImage"
104
+
105
+ android:layout_width="130dp"
106
+
107
+ android:layout_height="200dp"
108
+
109
+ android:layout_marginStart="8dp"
110
+
111
+ android:layout_marginTop="8dp"
112
+
113
+ android:layout_marginEnd="8dp"
114
+
115
+ android:layout_marginBottom="8dp"
116
+
117
+ android:scaleType="fitCenter"
118
+
119
+ app:layout_constraintBottom_toBottomOf="parent"
120
+
121
+ app:layout_constraintEnd_toEndOf="parent"
122
+
123
+ app:layout_constraintStart_toStartOf="parent"
124
+
125
+ app:layout_constraintTop_toBottomOf="@+id/resultLabel"
126
+
127
+ app:srcCompat="@drawable/com_gu" />
128
+
129
+
130
+
131
+ <Button
132
+
133
+ android:id="@+id/backButton"
134
+
135
+ android:layout_width="wrap_content"
136
+
137
+ android:layout_height="wrap_content"
138
+
139
+ android:layout_marginStart="16dp"
140
+
141
+ android:layout_marginTop="4dp"
142
+
143
+ android:text="@string/back_text"
144
+
145
+ app:layout_constraintStart_toStartOf="parent"
146
+
147
+ app:layout_constraintTop_toTopOf="parent" />
148
+
149
+
150
+
151
+ <ImageButton
152
+
153
+ android:id="@+id/imageButton3"
154
+
155
+ android:layout_width="100dp"
156
+
157
+ android:layout_height="100dp"
158
+
159
+ android:scaleType="fitCenter"
160
+
161
+ app:layout_constraintBottom_toBottomOf="parent"
162
+
163
+ app:layout_constraintEnd_toStartOf="@+id/comHandImage"
164
+
165
+ app:layout_constraintTop_toBottomOf="@+id/resultLabel"
166
+
167
+ app:srcCompat="@drawable/irasutoyahappy" />
168
+
169
+
170
+
171
+ <ImageButton
172
+
173
+ android:id="@+id/imageButton4"
174
+
175
+ android:layout_width="100dp"
176
+
177
+ android:layout_height="100dp"
178
+
179
+ android:scaleType="fitCenter"
180
+
181
+ app:layout_constraintBottom_toBottomOf="parent"
182
+
183
+ app:layout_constraintStart_toEndOf="@+id/comHandImage"
184
+
185
+ app:layout_constraintTop_toBottomOf="@+id/resultLabel"
186
+
187
+ app:srcCompat="@drawable/irasutoyahappy" />
188
+
189
+
190
+
191
+ <Button
192
+
193
+ android:id="@+id/nextButton"
194
+
195
+ android:layout_width="wrap_content"
196
+
197
+ android:layout_height="wrap_content"
198
+
199
+ android:text="次へ"
200
+
201
+ app:layout_constraintTop_toTopOf="parent"
202
+
203
+ app:layout_constraintRight_toRightOf="parent"
204
+
205
+ android:layout_marginEnd="16dp"
206
+
207
+ android:layout_marginTop="4dp"
208
+
209
+ />
210
+
211
+
212
+
213
+ </androidx.constraintlayout.widget.ConstraintLayout>
214
+
215
+ ```
216
+
217
+
218
+
219
+ 以上、よろしくお願いいたします。

1

修正

2020/12/20 08:05

投稿

razuma
razuma

スコア1313

test CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  xmlファイルはCodeかSplitを押すとコードが出てきますのでそちらを押してみてください。
4
4
 
5
+ (回答についてはxmlの状況などを見てから別途追記予定)
6
+
5
7
 
6
8
 
7
9
  ![イメージ説明](3d2d59b3d745708ff32dd645a3e495b1.png)