質問編集履歴
1
文法の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
###fragamentで覆ったmain画面のボタンが浮き出る。
|
2
|
-
|
2
|
+
Android studioでノベルゲームを作っています。今、以下のようなオプション画面を実現したく奮闘しています。
|
3
3
|

|
4
|
-
しかし、
|
4
|
+
しかし、オプションをfragmentで作ると以下の画像のようにゲームスタート画面のボタンが浮き出てしまいます。さらにそれを押せてしまいます。(本来ならcreditとtwitterでいい。)
|
5
5
|

|
6
6
|
以前もこの画面構築について相談させていただいたのですが、そのとき「背景を半透明にしたレイアウトの中にオプション画面を入れ、そのレイアウトをFragmentに設定して画面全体に表示されるよう配置すればいい」というアドバイスをいただきました。
|
7
7
|
それに基づいて画面を作ったのですが、やはり浮き出てしまいます。
|
8
|
-
以下にコードを載せます。これをどのように改造すればよいのでしょうか?
|
8
|
+
以下にコードを載せます。これをどのように改造すればよいのでしょうか?指針だけでも教えていただけたらありがたいです・・・・
|
9
9
|
fragment_option.xml
|
10
10
|
```lang-xml
|
11
11
|
<?xml version="1.0" encoding="utf-8"?>
|
@@ -76,59 +76,7 @@
|
|
76
76
|
android:layout_height="match_parent"
|
77
77
|
android:background="@color/colorPrimaryDark"
|
78
78
|
tools:context=".TitleActivity">
|
79
|
-
|
80
|
-
|
81
|
-
<TextView
|
82
|
-
android:id="@+id/title"
|
83
|
-
android:layout_width="wrap_content"
|
84
|
-
android:layout_height="wrap_content"
|
85
|
-
android:layout_marginEnd="8dp"
|
86
|
-
android:layout_marginLeft="8dp"
|
87
|
-
android:layout_marginRight="8dp"
|
88
|
-
android:layout_marginStart="8dp"
|
89
|
-
android:layout_marginTop="170dp"
|
90
|
-
android:text="@string/title"
|
91
|
-
android:textColor="@color/colorAccent"
|
92
|
-
android:textSize="24sp"
|
93
|
-
app:layout_constraintEnd_toEndOf="parent"
|
94
|
-
app:layout_constraintStart_toStartOf="parent"
|
95
|
-
app:layout_constraintTop_toTopOf="parent" />
|
96
|
-
|
97
|
-
|
79
|
+
---略
|
98
|
-
android:id="@+id/button_start"
|
99
|
-
android:layout_width="wrap_content"
|
100
|
-
android:layout_height="wrap_content"
|
101
|
-
android:layout_marginEnd="8dp"
|
102
|
-
android:layout_marginLeft="8dp"
|
103
|
-
android:layout_marginRight="8dp"
|
104
|
-
android:layout_marginStart="8dp"
|
105
|
-
android:layout_marginTop="64dp"
|
106
|
-
android:onClick="launchSelectActivity"
|
107
|
-
android:text="@string/button_start"
|
108
|
-
android:textSize="30dp"
|
109
|
-
app:layout_constraintEnd_toEndOf="parent"
|
110
|
-
app:layout_constraintStart_toStartOf="parent"
|
111
|
-
app:layout_constraintTop_toBottomOf="@+id/title" />
|
112
|
-
|
113
|
-
<Button
|
114
|
-
android:id="@+id/gallery"
|
115
|
-
android:layout_width="wrap_content"
|
116
|
-
android:layout_height="wrap_content"
|
117
|
-
android:layout_marginTop="32dp"
|
118
|
-
android:text="@string/gallery"
|
119
|
-
app:layout_constraintStart_toStartOf="@+id/button_start"
|
120
|
-
app:layout_constraintTop_toBottomOf="@+id/button_start" />
|
121
|
-
|
122
|
-
<Button
|
123
|
-
android:id="@+id/option"
|
124
|
-
android:layout_width="wrap_content"
|
125
|
-
android:layout_height="wrap_content"
|
126
|
-
android:layout_marginTop="32dp"
|
127
|
-
android:text="@string/option"
|
128
|
-
android:onClick="goOption"
|
129
|
-
app:layout_constraintEnd_toEndOf="@+id/button_start"
|
130
|
-
app:layout_constraintTop_toBottomOf="@+id/button_start" />
|
131
|
-
|
132
80
|
<FrameLayout
|
133
81
|
android:id="@+id/fragment"
|
134
82
|
android:name="com.example.android.test.OptionFragment"
|
@@ -141,95 +89,4 @@
|
|
141
89
|
|
142
90
|
|
143
91
|
</android.support.constraint.ConstraintLayout>
|
144
|
-
```
|
145
|
-
OptionFragmnt
|
146
|
-
```lang-java
|
147
|
-
package com.example.android.test;
|
148
|
-
|
149
|
-
|
150
|
-
import android.os.Build;
|
151
|
-
import android.os.Bundle;
|
152
|
-
|
153
|
-
import android.support.v4.app.Fragment;
|
154
|
-
import android.view.LayoutInflater;
|
155
|
-
import android.view.View;
|
156
|
-
import android.view.ViewGroup;
|
157
|
-
import android.widget.TextView;
|
158
|
-
|
159
|
-
/**
|
160
|
-
* A simple {@link Fragment} subclass.
|
161
|
-
*/
|
162
|
-
public class OptionFragment extends Fragment {
|
163
|
-
|
164
|
-
|
165
|
-
public OptionFragment() {
|
166
|
-
// Required empty public constructor
|
167
|
-
}
|
168
|
-
|
169
|
-
@Override
|
170
|
-
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
171
|
-
Bundle savedInstanceState) {
|
172
|
-
final View rootView =
|
173
|
-
inflater.inflate(R.layout.fragment_option, container, false);
|
174
|
-
return rootView;
|
175
|
-
}
|
176
|
-
|
177
|
-
public void goTwitter(View view) {
|
178
|
-
}
|
179
|
-
|
180
|
-
public void goCredit(View view) {
|
181
|
-
}
|
182
|
-
}
|
183
|
-
|
184
|
-
```
|
185
|
-
TitleActivity
|
186
|
-
```lang-java
|
187
|
-
package com.example.android.test;
|
188
|
-
|
189
|
-
import android.app.Activity;
|
190
|
-
import android.app.Dialog;
|
191
|
-
import android.content.Intent;
|
192
|
-
import android.media.AudioAttributes;
|
193
|
-
import android.media.SoundPool;
|
194
|
-
import android.net.Uri;
|
195
|
-
import android.os.Build;
|
196
|
-
import android.os.Bundle;
|
197
|
-
import android.support.v4.app.DialogFragment;
|
198
|
-
import android.support.v4.app.FragmentActivity;
|
199
|
-
import android.support.v4.app.FragmentManager;
|
200
|
-
import android.support.v4.app.FragmentTransaction;
|
201
|
-
import android.support.v7.app.AppCompatActivity;
|
202
|
-
import android.view.View;
|
203
|
-
import android.widget.Button;
|
204
|
-
import android.widget.TextView;
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
public class TitleActivity extends FragmentActivity {
|
209
|
-
|
210
|
-
@Override
|
211
|
-
protected void onCreate(Bundle savedInstanceState) {
|
212
|
-
super.onCreate(savedInstanceState);
|
213
|
-
setContentView(R.layout.activity_title);
|
214
|
-
|
215
|
-
}
|
216
|
-
public void launchSelectActivity(View view) {
|
217
|
-
soundPool.play(soundGo, 1.0f, 1.0f, 0, 0, 1);
|
218
|
-
Intent intent = new Intent(this, SelectActivity.class);
|
219
|
-
startActivity(intent);
|
220
|
-
}
|
221
|
-
|
222
|
-
public void goOption(View view) {//オプションボタンを押したときの処理。
|
223
|
-
|
224
|
-
FragmentManager manager=getSupportFragmentManager();
|
225
|
-
FragmentTransaction transaction=manager.beginTransaction();
|
226
|
-
OptionFragment op =new OptionFragment();
|
227
|
-
transaction.add(R.id.fragment,op);
|
228
|
-
transaction.commit();
|
229
|
-
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
}
|
234
|
-
|
235
92
|
```
|