回答編集履歴
5
追記
answer
CHANGED
@@ -145,4 +145,65 @@
|
|
145
145
|
android:layout_width="match_parent"
|
146
146
|
android:layout_height="match_parent"
|
147
147
|
```
|
148
|
-
が抜けています。私が書いた`activity_main.xml`を参照して入れてみてください。
|
148
|
+
が抜けています。私が書いた`activity_main.xml`を参照して入れてみてください。
|
149
|
+
|
150
|
+
```
|
151
|
+
<?xml version="1.0" encoding="utf-8"?>
|
152
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
153
|
+
android:layout_height="match_parent"
|
154
|
+
android:layout_width="match_parent"
|
155
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
156
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
157
|
+
xmlns:tools="http://schemas.android.com/tools">
|
158
|
+
|
159
|
+
<Button
|
160
|
+
android:id="@+id/choki"
|
161
|
+
android:layout_width="100dp"
|
162
|
+
android:layout_height="100dp"
|
163
|
+
android:layout_marginStart="8dp"
|
164
|
+
android:layout_marginTop="8dp"
|
165
|
+
android:layout_marginEnd="8dp"
|
166
|
+
android:layout_marginBottom="8dp"
|
167
|
+
android:scaleType="fitCenter"
|
168
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
169
|
+
app:layout_constraintEnd_toEndOf="parent"
|
170
|
+
app:layout_constraintStart_toStartOf="parent"
|
171
|
+
app:layout_constraintTop_toTopOf="parent"
|
172
|
+
app:srcCompat="@drawable/choki" />
|
173
|
+
|
174
|
+
<ImageButton
|
175
|
+
android:id="@+id/pa"
|
176
|
+
android:layout_width="100dp"
|
177
|
+
android:layout_height="100dp"
|
178
|
+
android:layout_marginStart="8dp"
|
179
|
+
android:scaleType="fitCenter"
|
180
|
+
app:layout_constraintStart_toEndOf="@+id/choki"
|
181
|
+
app:layout_constraintTop_toTopOf="@+id/choki"
|
182
|
+
app:srcCompat="@drawable/pa" />
|
183
|
+
|
184
|
+
<ImageButton
|
185
|
+
android:id="@+id/gu"
|
186
|
+
android:layout_width="100dp"
|
187
|
+
android:layout_height="100dp"
|
188
|
+
android:layout_marginEnd="8dp"
|
189
|
+
android:scaleType="fitCenter"
|
190
|
+
app:layout_constraintEnd_toStartOf="@+id/choki"
|
191
|
+
app:layout_constraintTop_toTopOf="@+id/choki"
|
192
|
+
app:srcCompat="@drawable/gu" />
|
193
|
+
|
194
|
+
<TextView
|
195
|
+
android:id="@+id/textView"
|
196
|
+
android:layout_width="wrap_content"
|
197
|
+
android:layout_height="wrap_content"
|
198
|
+
android:layout_marginStart="8dp"
|
199
|
+
android:layout_marginTop="8dp"
|
200
|
+
android:layout_marginEnd="8dp"
|
201
|
+
android:layout_marginBottom="8dp"
|
202
|
+
android:text="@string/janken_text"
|
203
|
+
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
204
|
+
app:layout_constraintBottom_toTopOf="@+id/choki"
|
205
|
+
app:layout_constraintEnd_toEndOf="parent"
|
206
|
+
app:layout_constraintStart_toStartOf="parent"
|
207
|
+
app:layout_constraintTop_toTopOf="parent" />
|
208
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
209
|
+
```
|
4
回答追記
answer
CHANGED
@@ -137,4 +137,12 @@
|
|
137
137
|
startActivity(intent)
|
138
138
|
}
|
139
139
|
}
|
140
|
-
```
|
140
|
+
```
|
141
|
+
|
142
|
+
===追記
|
143
|
+
`activity_main.xml`の一番上の層の`ConstraintLayout`にて
|
144
|
+
```
|
145
|
+
android:layout_width="match_parent"
|
146
|
+
android:layout_height="match_parent"
|
147
|
+
```
|
148
|
+
が抜けています。私が書いた`activity_main.xml`を参照して入れてみてください。
|
3
追記
answer
CHANGED
@@ -107,4 +107,34 @@
|
|
107
107
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
108
108
|
```
|
109
109
|
|
110
|
-
以上、よろしくお願いいたします。
|
110
|
+
以上、よろしくお願いいたします。
|
111
|
+
|
112
|
+
=== 追記
|
113
|
+
真っ白になるとのことですが、MainActivityが2重になって書かれているので1つ削除してください
|
114
|
+
|
115
|
+
```
|
116
|
+
class MainActivity : AppCompatActivity() {
|
117
|
+
|
118
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
119
|
+
super.onCreate(savedInstanceState)
|
120
|
+
setContentView(R.layout.activity_main)
|
121
|
+
|
122
|
+
gu.setOnClickListener { onJankenButtonTapped(it) }
|
123
|
+
choki.setOnClickListener { onJankenButtonTapped(it) }
|
124
|
+
pa.setOnClickListener { onJankenButtonTapped(it) }
|
125
|
+
|
126
|
+
val pref = PreferenceManager.getDefaultSharedPreferences(this)
|
127
|
+
pref.edit {
|
128
|
+
clear()
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
fun onJankenButtonTapped(view: View1?) {
|
133
|
+
val streak = this.intent.getIntExtra("streak", 0)
|
134
|
+
val intent = Intent(this, ResultActivity::class.java)
|
135
|
+
intent.putExtra("MY_HAND", view?.id)
|
136
|
+
intent.putExtra("streak", streak)
|
137
|
+
startActivity(intent)
|
138
|
+
}
|
139
|
+
}
|
140
|
+
```
|
2
追記
answer
CHANGED
@@ -2,4 +2,109 @@
|
|
2
2
|
xmlファイルはCodeかSplitを押すとコードが出てきますのでそちらを押してみてください。
|
3
3
|
(回答についてはxmlの状況などを見てから別途追記予定)
|
4
4
|
|
5
|
-

|
5
|
+

|
6
|
+
|
7
|
+
===追記
|
8
|
+
activity_result.xmlにて`tools:layout_editor_absoluteX`や`tools:layout_editor_absoluteY`が使われています。
|
9
|
+
こちらはツール上ではレイアウトされているように見えますが実行した際には意味をなさない値です。
|
10
|
+
表示上と同じように見えるように書き換えてみましたが以下にすることで問題は解決しないでしょうか。
|
11
|
+
|
12
|
+
```
|
13
|
+
<?xml version="1.0" encoding="utf-8"?>
|
14
|
+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
15
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
16
|
+
xmlns:tools="http://schemas.android.com/tools"
|
17
|
+
android:layout_width="match_parent"
|
18
|
+
android:layout_height="match_parent"
|
19
|
+
tools:context=".ResultActivity">
|
20
|
+
|
21
|
+
<TextView
|
22
|
+
android:id="@+id/resultLabel"
|
23
|
+
android:layout_width="wrap_content"
|
24
|
+
android:layout_height="wrap_content"
|
25
|
+
android:layout_marginStart="8dp"
|
26
|
+
android:layout_marginTop="8dp"
|
27
|
+
android:layout_marginEnd="8dp"
|
28
|
+
android:layout_marginBottom="8dp"
|
29
|
+
android:text="TextView"
|
30
|
+
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
31
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
32
|
+
app:layout_constraintEnd_toEndOf="parent"
|
33
|
+
app:layout_constraintStart_toStartOf="parent"
|
34
|
+
app:layout_constraintTop_toTopOf="parent" />
|
35
|
+
|
36
|
+
<ImageView
|
37
|
+
android:id="@+id/myHandImage"
|
38
|
+
android:layout_width="160dp"
|
39
|
+
android:layout_height="160dp"
|
40
|
+
android:layout_marginStart="8dp"
|
41
|
+
android:layout_marginTop="8dp"
|
42
|
+
android:layout_marginEnd="8dp"
|
43
|
+
android:layout_marginBottom="8dp"
|
44
|
+
android:scaleType="fitCenter"
|
45
|
+
app:layout_constraintBottom_toTopOf="@+id/resultLabel"
|
46
|
+
app:layout_constraintEnd_toEndOf="parent"
|
47
|
+
app:layout_constraintStart_toStartOf="parent"
|
48
|
+
app:layout_constraintTop_toTopOf="parent"
|
49
|
+
app:srcCompat="@drawable/gu" />
|
50
|
+
|
51
|
+
<ImageView
|
52
|
+
android:id="@+id/comHandImage"
|
53
|
+
android:layout_width="130dp"
|
54
|
+
android:layout_height="200dp"
|
55
|
+
android:layout_marginStart="8dp"
|
56
|
+
android:layout_marginTop="8dp"
|
57
|
+
android:layout_marginEnd="8dp"
|
58
|
+
android:layout_marginBottom="8dp"
|
59
|
+
android:scaleType="fitCenter"
|
60
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
61
|
+
app:layout_constraintEnd_toEndOf="parent"
|
62
|
+
app:layout_constraintStart_toStartOf="parent"
|
63
|
+
app:layout_constraintTop_toBottomOf="@+id/resultLabel"
|
64
|
+
app:srcCompat="@drawable/com_gu" />
|
65
|
+
|
66
|
+
<Button
|
67
|
+
android:id="@+id/backButton"
|
68
|
+
android:layout_width="wrap_content"
|
69
|
+
android:layout_height="wrap_content"
|
70
|
+
android:layout_marginStart="16dp"
|
71
|
+
android:layout_marginTop="4dp"
|
72
|
+
android:text="@string/back_text"
|
73
|
+
app:layout_constraintStart_toStartOf="parent"
|
74
|
+
app:layout_constraintTop_toTopOf="parent" />
|
75
|
+
|
76
|
+
<ImageButton
|
77
|
+
android:id="@+id/imageButton3"
|
78
|
+
android:layout_width="100dp"
|
79
|
+
android:layout_height="100dp"
|
80
|
+
android:scaleType="fitCenter"
|
81
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
82
|
+
app:layout_constraintEnd_toStartOf="@+id/comHandImage"
|
83
|
+
app:layout_constraintTop_toBottomOf="@+id/resultLabel"
|
84
|
+
app:srcCompat="@drawable/irasutoyahappy" />
|
85
|
+
|
86
|
+
<ImageButton
|
87
|
+
android:id="@+id/imageButton4"
|
88
|
+
android:layout_width="100dp"
|
89
|
+
android:layout_height="100dp"
|
90
|
+
android:scaleType="fitCenter"
|
91
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
92
|
+
app:layout_constraintStart_toEndOf="@+id/comHandImage"
|
93
|
+
app:layout_constraintTop_toBottomOf="@+id/resultLabel"
|
94
|
+
app:srcCompat="@drawable/irasutoyahappy" />
|
95
|
+
|
96
|
+
<Button
|
97
|
+
android:id="@+id/nextButton"
|
98
|
+
android:layout_width="wrap_content"
|
99
|
+
android:layout_height="wrap_content"
|
100
|
+
android:text="次へ"
|
101
|
+
app:layout_constraintTop_toTopOf="parent"
|
102
|
+
app:layout_constraintRight_toRightOf="parent"
|
103
|
+
android:layout_marginEnd="16dp"
|
104
|
+
android:layout_marginTop="4dp"
|
105
|
+
/>
|
106
|
+
|
107
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
108
|
+
```
|
109
|
+
|
110
|
+
以上、よろしくお願いいたします。
|
1
修正
answer
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
スクリーンショットが貼れないのでこちらに貼ります。
|
2
2
|
xmlファイルはCodeかSplitを押すとコードが出てきますのでそちらを押してみてください。
|
3
|
+
(回答についてはxmlの状況などを見てから別途追記予定)
|
3
4
|
|
4
5
|

|