質問編集履歴
1
ソースコードを載せました。追加で画像を添付しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,9 +30,253 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
```
|
33
|
+
```Java
|
34
|
+
|
34
|
-
|
35
|
+
import android.os.Bundle;
|
36
|
+
|
37
|
+
import android.support.design.widget.FloatingActionButton;
|
38
|
+
|
39
|
+
import android.support.design.widget.Snackbar;
|
40
|
+
|
41
|
+
import android.view.View;
|
42
|
+
|
43
|
+
import android.support.design.widget.NavigationView;
|
44
|
+
|
45
|
+
import android.support.v4.view.GravityCompat;
|
46
|
+
|
47
|
+
import android.support.v4.widget.DrawerLayout;
|
48
|
+
|
49
|
+
import android.support.v7.app.ActionBarDrawerToggle;
|
50
|
+
|
51
|
+
import android.support.v7.app.AppCompatActivity;
|
52
|
+
|
53
|
+
import android.support.v7.widget.Toolbar;
|
54
|
+
|
55
|
+
import android.view.Menu;
|
56
|
+
|
57
|
+
import android.view.MenuItem;
|
58
|
+
|
59
|
+
import android.widget.SeekBar;
|
60
|
+
|
61
|
+
import android.widget.TextView;
|
62
|
+
|
63
|
+
import java.util.Locale;
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
public class MainActivity extends AppCompatActivity
|
68
|
+
|
69
|
+
implements NavigationView.OnNavigationItemSelectedListener {
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
private TextView numberView1;
|
76
|
+
|
77
|
+
private TextView numberView2;
|
78
|
+
|
79
|
+
private TextView numberView3;
|
80
|
+
|
81
|
+
private TextView numberView4;
|
82
|
+
|
83
|
+
private TextView numberView5;
|
84
|
+
|
85
|
+
private TextView numberView6;
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
@Override
|
90
|
+
|
91
|
+
protected void onCreate(Bundle savedInstanceState) {
|
92
|
+
|
93
|
+
super.onCreate(savedInstanceState);
|
94
|
+
|
95
|
+
setContentView(R.layout.activity_main);
|
96
|
+
|
97
|
+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
98
|
+
|
99
|
+
setSupportActionBar(toolbar);
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
numberView1 = findViewById(R.id.numberView1);
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
SeekBar seekBar1 = findViewById(R.id.seekBar1);
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
seekBar1.setProgress(0);
|
112
|
+
|
113
|
+
seekBar1.setMax(100);
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
seekBar1.setOnSeekBarChangeListener(
|
118
|
+
|
119
|
+
new SeekBar.OnSeekBarChangeListener() {
|
120
|
+
|
121
|
+
@Override
|
122
|
+
|
123
|
+
public void onProgressChanged(
|
124
|
+
|
125
|
+
SeekBar seekBar1, int progress, boolean fromUser) {
|
126
|
+
|
127
|
+
String str = String.format(Locale.US, "%d %%",progress);
|
128
|
+
|
129
|
+
numberView1.setText(str);
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
@Override
|
134
|
+
|
135
|
+
public void onStartTrackingTouch(SeekBar seekBar1) {
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
public void onStopTrackingTouch(SeekBar seekBar1) {
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
);
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
/*長すぎたので省略しますが、6個同じようなことが書いてあります
|
152
|
+
|
153
|
+
これは後からボタンを押したときにSeekBarとかNumberViewとかをセットで増やすようにする予定だからです
|
154
|
+
|
35
|
-
|
155
|
+
*/
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
160
|
+
|
161
|
+
fab.setOnClickListener(new View.OnClickListener() {
|
162
|
+
|
163
|
+
@Override
|
164
|
+
|
165
|
+
public void onClick(View view) {
|
166
|
+
|
167
|
+
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
168
|
+
|
169
|
+
.setAction("Action", null).show();
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
});
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
178
|
+
|
179
|
+
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
180
|
+
|
181
|
+
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
182
|
+
|
183
|
+
drawer.addDrawerListener(toggle);
|
184
|
+
|
185
|
+
toggle.syncState();
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
190
|
+
|
191
|
+
navigationView.setNavigationItemSelectedListener(this);
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
@Override
|
198
|
+
|
199
|
+
public void onBackPressed() {
|
200
|
+
|
201
|
+
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
202
|
+
|
203
|
+
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
204
|
+
|
205
|
+
drawer.closeDrawer(GravityCompat.START);
|
206
|
+
|
207
|
+
} else {
|
208
|
+
|
209
|
+
super.onBackPressed();
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
@Override
|
218
|
+
|
219
|
+
public boolean onCreateOptionsMenu(Menu menu) {
|
220
|
+
|
221
|
+
// Inflate the menu; this adds items to the action bar if it is present.
|
222
|
+
|
223
|
+
getMenuInflater().inflate(R.menu.main, menu);
|
224
|
+
|
225
|
+
return true;
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
@Override
|
232
|
+
|
233
|
+
public boolean onOptionsItemSelected(MenuItem item) {
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
int id = item.getItemId();
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
//noinspection SimplifiableIfStatement
|
242
|
+
|
243
|
+
if (id == R.id.action_settings) {
|
244
|
+
|
245
|
+
return true;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
return super.onOptionsItemSelected(item);
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
@SuppressWarnings("StatementWithEmptyBody")
|
258
|
+
|
259
|
+
@Override
|
260
|
+
|
261
|
+
public boolean onNavigationItemSelected(MenuItem item) {
|
262
|
+
|
263
|
+
// Handle navigation view item clicks here.
|
264
|
+
|
265
|
+
int id = item.getItemId();
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
270
|
+
|
271
|
+
drawer.closeDrawer(GravityCompat.START);
|
272
|
+
|
273
|
+
return true;
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
}
|
36
280
|
|
37
281
|
```
|
38
282
|
|
@@ -50,4 +294,176 @@
|
|
50
294
|
|
51
295
|
|
52
296
|
|
297
|
+
ソースコードに載せたのはJavaのMainActivityです
|
298
|
+
|
53
|
-
|
299
|
+
変えたのはほとんどレイアウトとかだけです
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
Content_main.xmlはこちらになります
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
<?xml version="1.0" encoding="utf-8"?>
|
308
|
+
|
309
|
+
<android.support.constraint.ConstraintLayout 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
|
+
android:layout_width="match_parent"
|
316
|
+
|
317
|
+
android:layout_height="match_parent"
|
318
|
+
|
319
|
+
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
320
|
+
|
321
|
+
tools:context=".MainActivity"
|
322
|
+
|
323
|
+
tools:showIn="@layout/app_bar_main">
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
<ScrollView
|
328
|
+
|
329
|
+
android:id="@+id/ScrollView"
|
330
|
+
|
331
|
+
android:layout_width="fill_parent"
|
332
|
+
|
333
|
+
android:layout_height="fill_parent">
|
334
|
+
|
335
|
+
<LinearLayout
|
336
|
+
|
337
|
+
android:id="@+id/LinearLayout"
|
338
|
+
|
339
|
+
android:orientation="vertical"
|
340
|
+
|
341
|
+
android:layout_width="fill_parent"
|
342
|
+
|
343
|
+
android:layout_height="fill_parent">
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
<LinearLayout
|
348
|
+
|
349
|
+
android:layout_width="match_parent"
|
350
|
+
|
351
|
+
android:layout_height="match_parent"
|
352
|
+
|
353
|
+
android:orientation="vertical">
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
<TextView
|
358
|
+
|
359
|
+
android:id="@+id/textView1"
|
360
|
+
|
361
|
+
android:layout_width="wrap_content"
|
362
|
+
|
363
|
+
android:layout_height="wrap_content"
|
364
|
+
|
365
|
+
android:layout_marginStart="16dp"
|
366
|
+
|
367
|
+
android:layout_marginLeft="16dp"
|
368
|
+
|
369
|
+
android:layout_marginTop="5dp"
|
370
|
+
|
371
|
+
android:layout_marginEnd="0dp"
|
372
|
+
|
373
|
+
android:layout_marginRight="0dp"
|
374
|
+
|
375
|
+
android:text="元気!"
|
376
|
+
|
377
|
+
android:textSize="24sp"
|
378
|
+
|
379
|
+
app:layout_constraintBottom_toTopOf="@+id/seekBar2"
|
380
|
+
|
381
|
+
app:layout_constraintEnd_toEndOf="parent"
|
382
|
+
|
383
|
+
app:layout_constraintHorizontal_bias="0.0"
|
384
|
+
|
385
|
+
app:layout_constraintStart_toStartOf="parent"
|
386
|
+
|
387
|
+
app:layout_constraintTop_toTopOf="parent" />
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
<TextView
|
392
|
+
|
393
|
+
android:id="@+id/numberView1"
|
394
|
+
|
395
|
+
android:layout_width="wrap_content"
|
396
|
+
|
397
|
+
android:layout_height="wrap_content"
|
398
|
+
|
399
|
+
android:layout_marginStart="150dp"
|
400
|
+
|
401
|
+
android:layout_marginLeft="120dp"
|
402
|
+
|
403
|
+
android:layout_marginTop="0dp"
|
404
|
+
|
405
|
+
android:layout_marginEnd="0dp"
|
406
|
+
|
407
|
+
android:layout_marginRight="0dp"
|
408
|
+
|
409
|
+
android:layout_marginBottom="0dp"
|
410
|
+
|
411
|
+
android:text=""
|
412
|
+
|
413
|
+
android:textSize="18sp"
|
414
|
+
|
415
|
+
app:layout_constraintBottom_toTopOf="@+id/seekBar1"
|
416
|
+
|
417
|
+
app:layout_constraintEnd_toEndOf="parent"
|
418
|
+
|
419
|
+
app:layout_constraintHorizontal_bias="0.491"
|
420
|
+
|
421
|
+
app:layout_constraintStart_toEndOf="@+id/textView1"
|
422
|
+
|
423
|
+
app:layout_constraintTop_toTopOf="parent"
|
424
|
+
|
425
|
+
app:layout_constraintVertical_bias="0.544" />
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
<SeekBar
|
430
|
+
|
431
|
+
android:id="@+id/seekBar1"
|
432
|
+
|
433
|
+
android:layout_width="347dp"
|
434
|
+
|
435
|
+
android:layout_height="44dp"
|
436
|
+
|
437
|
+
android:layout_marginStart="18dp"
|
438
|
+
|
439
|
+
android:layout_marginLeft="18dp"
|
440
|
+
|
441
|
+
android:layout_marginTop="0dp"
|
442
|
+
|
443
|
+
android:layout_marginEnd="0dp"
|
444
|
+
|
445
|
+
android:layout_marginRight="0dp"
|
446
|
+
|
447
|
+
app:layout_constraintBottom_toTopOf="@+id/textView1"
|
448
|
+
|
449
|
+
app:layout_constraintEnd_toEndOf="parent"
|
450
|
+
|
451
|
+
app:layout_constraintStart_toStartOf="parent"
|
452
|
+
|
453
|
+
app:layout_constraintTop_toBottomOf="@+id/textView1" />
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
</LinearLayout>
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
<!--これも同じように6個ぐらいあります。-->
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
</LinearLayout>
|
466
|
+
|
467
|
+
</ScrollView>
|
468
|
+
|
469
|
+
</android.support.constraint.ConstraintLayout>
|