質問編集履歴
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
###fragamentで覆ったmain画面のボタンが浮き出る。
|
2
2
|
|
3
|
-
|
3
|
+
Android studioでノベルゲームを作っています。今、以下のようなオプション画面を実現したく奮闘しています。
|
4
4
|
|
5
5
|
![![イメージ説明](a49b00aa0107819840cf43e8e6703929.png)
|
6
6
|
|
7
|
-
しかし、
|
7
|
+
しかし、オプションをfragmentで作ると以下の画像のようにゲームスタート画面のボタンが浮き出てしまいます。さらにそれを押せてしまいます。(本来ならcreditとtwitterでいい。)
|
8
8
|
|
9
9
|
![イメージ説明](0ef914ad478d381fbda95f099058898f.png)
|
10
10
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
それに基づいて画面を作ったのですが、やはり浮き出てしまいます。
|
14
14
|
|
15
|
-
以下にコードを載せます。これをどのように改造すればよいのでしょうか?
|
15
|
+
以下にコードを載せます。これをどのように改造すればよいのでしょうか?指針だけでも教えていただけたらありがたいです・・・・
|
16
16
|
|
17
17
|
fragment_option.xml
|
18
18
|
|
@@ -154,111 +154,7 @@
|
|
154
154
|
|
155
155
|
tools:context=".TitleActivity">
|
156
156
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
<TextView
|
162
|
-
|
163
|
-
android:id="@+id/title"
|
164
|
-
|
165
|
-
android:layout_width="wrap_content"
|
166
|
-
|
167
|
-
android:layout_height="wrap_content"
|
168
|
-
|
169
|
-
android:layout_marginEnd="8dp"
|
170
|
-
|
171
|
-
android:layout_marginLeft="8dp"
|
172
|
-
|
173
|
-
android:layout_marginRight="8dp"
|
174
|
-
|
175
|
-
android:layout_marginStart="8dp"
|
176
|
-
|
177
|
-
android:layout_marginTop="170dp"
|
178
|
-
|
179
|
-
android:text="@string/title"
|
180
|
-
|
181
|
-
android:textColor="@color/colorAccent"
|
182
|
-
|
183
|
-
android:textSize="24sp"
|
184
|
-
|
185
|
-
app:layout_constraintEnd_toEndOf="parent"
|
186
|
-
|
187
|
-
app:layout_constraintStart_toStartOf="parent"
|
188
|
-
|
189
|
-
app:layout_constraintTop_toTopOf="parent" />
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
157
|
+
---略
|
194
|
-
|
195
|
-
android:id="@+id/button_start"
|
196
|
-
|
197
|
-
android:layout_width="wrap_content"
|
198
|
-
|
199
|
-
android:layout_height="wrap_content"
|
200
|
-
|
201
|
-
android:layout_marginEnd="8dp"
|
202
|
-
|
203
|
-
android:layout_marginLeft="8dp"
|
204
|
-
|
205
|
-
android:layout_marginRight="8dp"
|
206
|
-
|
207
|
-
android:layout_marginStart="8dp"
|
208
|
-
|
209
|
-
android:layout_marginTop="64dp"
|
210
|
-
|
211
|
-
android:onClick="launchSelectActivity"
|
212
|
-
|
213
|
-
android:text="@string/button_start"
|
214
|
-
|
215
|
-
android:textSize="30dp"
|
216
|
-
|
217
|
-
app:layout_constraintEnd_toEndOf="parent"
|
218
|
-
|
219
|
-
app:layout_constraintStart_toStartOf="parent"
|
220
|
-
|
221
|
-
app:layout_constraintTop_toBottomOf="@+id/title" />
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
<Button
|
226
|
-
|
227
|
-
android:id="@+id/gallery"
|
228
|
-
|
229
|
-
android:layout_width="wrap_content"
|
230
|
-
|
231
|
-
android:layout_height="wrap_content"
|
232
|
-
|
233
|
-
android:layout_marginTop="32dp"
|
234
|
-
|
235
|
-
android:text="@string/gallery"
|
236
|
-
|
237
|
-
app:layout_constraintStart_toStartOf="@+id/button_start"
|
238
|
-
|
239
|
-
app:layout_constraintTop_toBottomOf="@+id/button_start" />
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
<Button
|
244
|
-
|
245
|
-
android:id="@+id/option"
|
246
|
-
|
247
|
-
android:layout_width="wrap_content"
|
248
|
-
|
249
|
-
android:layout_height="wrap_content"
|
250
|
-
|
251
|
-
android:layout_marginTop="32dp"
|
252
|
-
|
253
|
-
android:text="@string/option"
|
254
|
-
|
255
|
-
android:onClick="goOption"
|
256
|
-
|
257
|
-
app:layout_constraintEnd_toEndOf="@+id/button_start"
|
258
|
-
|
259
|
-
app:layout_constraintTop_toBottomOf="@+id/button_start" />
|
260
|
-
|
261
|
-
|
262
158
|
|
263
159
|
<FrameLayout
|
264
160
|
|
@@ -285,185 +181,3 @@
|
|
285
181
|
</android.support.constraint.ConstraintLayout>
|
286
182
|
|
287
183
|
```
|
288
|
-
|
289
|
-
OptionFragmnt
|
290
|
-
|
291
|
-
```lang-java
|
292
|
-
|
293
|
-
package com.example.android.test;
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
import android.os.Build;
|
300
|
-
|
301
|
-
import android.os.Bundle;
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
import android.support.v4.app.Fragment;
|
306
|
-
|
307
|
-
import android.view.LayoutInflater;
|
308
|
-
|
309
|
-
import android.view.View;
|
310
|
-
|
311
|
-
import android.view.ViewGroup;
|
312
|
-
|
313
|
-
import android.widget.TextView;
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
/**
|
318
|
-
|
319
|
-
* A simple {@link Fragment} subclass.
|
320
|
-
|
321
|
-
*/
|
322
|
-
|
323
|
-
public class OptionFragment extends Fragment {
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
public OptionFragment() {
|
330
|
-
|
331
|
-
// Required empty public constructor
|
332
|
-
|
333
|
-
}
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
@Override
|
338
|
-
|
339
|
-
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
340
|
-
|
341
|
-
Bundle savedInstanceState) {
|
342
|
-
|
343
|
-
final View rootView =
|
344
|
-
|
345
|
-
inflater.inflate(R.layout.fragment_option, container, false);
|
346
|
-
|
347
|
-
return rootView;
|
348
|
-
|
349
|
-
}
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
public void goTwitter(View view) {
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
public void goCredit(View view) {
|
360
|
-
|
361
|
-
}
|
362
|
-
|
363
|
-
}
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
```
|
368
|
-
|
369
|
-
TitleActivity
|
370
|
-
|
371
|
-
```lang-java
|
372
|
-
|
373
|
-
package com.example.android.test;
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
import android.app.Activity;
|
378
|
-
|
379
|
-
import android.app.Dialog;
|
380
|
-
|
381
|
-
import android.content.Intent;
|
382
|
-
|
383
|
-
import android.media.AudioAttributes;
|
384
|
-
|
385
|
-
import android.media.SoundPool;
|
386
|
-
|
387
|
-
import android.net.Uri;
|
388
|
-
|
389
|
-
import android.os.Build;
|
390
|
-
|
391
|
-
import android.os.Bundle;
|
392
|
-
|
393
|
-
import android.support.v4.app.DialogFragment;
|
394
|
-
|
395
|
-
import android.support.v4.app.FragmentActivity;
|
396
|
-
|
397
|
-
import android.support.v4.app.FragmentManager;
|
398
|
-
|
399
|
-
import android.support.v4.app.FragmentTransaction;
|
400
|
-
|
401
|
-
import android.support.v7.app.AppCompatActivity;
|
402
|
-
|
403
|
-
import android.view.View;
|
404
|
-
|
405
|
-
import android.widget.Button;
|
406
|
-
|
407
|
-
import android.widget.TextView;
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
public class TitleActivity extends FragmentActivity {
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
@Override
|
420
|
-
|
421
|
-
protected void onCreate(Bundle savedInstanceState) {
|
422
|
-
|
423
|
-
super.onCreate(savedInstanceState);
|
424
|
-
|
425
|
-
setContentView(R.layout.activity_title);
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
}
|
430
|
-
|
431
|
-
public void launchSelectActivity(View view) {
|
432
|
-
|
433
|
-
soundPool.play(soundGo, 1.0f, 1.0f, 0, 0, 1);
|
434
|
-
|
435
|
-
Intent intent = new Intent(this, SelectActivity.class);
|
436
|
-
|
437
|
-
startActivity(intent);
|
438
|
-
|
439
|
-
}
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
public void goOption(View view) {//オプションボタンを押したときの処理。
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
FragmentManager manager=getSupportFragmentManager();
|
448
|
-
|
449
|
-
FragmentTransaction transaction=manager.beginTransaction();
|
450
|
-
|
451
|
-
OptionFragment op =new OptionFragment();
|
452
|
-
|
453
|
-
transaction.add(R.id.fragment,op);
|
454
|
-
|
455
|
-
transaction.commit();
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
}
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
}
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
```
|