質問編集履歴
1
ソースコードを載せました。追加で画像を添付しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,8 +14,130 @@
|
|
14
14
|
|
15
15
|
### 該当のソースコード
|
16
16
|
|
17
|
-
```
|
17
|
+
```Java
|
18
|
+
import android.os.Bundle;
|
19
|
+
import android.support.design.widget.FloatingActionButton;
|
20
|
+
import android.support.design.widget.Snackbar;
|
21
|
+
import android.view.View;
|
22
|
+
import android.support.design.widget.NavigationView;
|
23
|
+
import android.support.v4.view.GravityCompat;
|
24
|
+
import android.support.v4.widget.DrawerLayout;
|
25
|
+
import android.support.v7.app.ActionBarDrawerToggle;
|
26
|
+
import android.support.v7.app.AppCompatActivity;
|
27
|
+
import android.support.v7.widget.Toolbar;
|
28
|
+
import android.view.Menu;
|
29
|
+
import android.view.MenuItem;
|
30
|
+
import android.widget.SeekBar;
|
31
|
+
import android.widget.TextView;
|
32
|
+
import java.util.Locale;
|
33
|
+
|
34
|
+
public class MainActivity extends AppCompatActivity
|
35
|
+
implements NavigationView.OnNavigationItemSelectedListener {
|
36
|
+
|
37
|
+
|
38
|
+
private TextView numberView1;
|
39
|
+
private TextView numberView2;
|
40
|
+
private TextView numberView3;
|
41
|
+
private TextView numberView4;
|
42
|
+
private TextView numberView5;
|
43
|
+
private TextView numberView6;
|
44
|
+
|
45
|
+
@Override
|
46
|
+
protected void onCreate(Bundle savedInstanceState) {
|
47
|
+
super.onCreate(savedInstanceState);
|
48
|
+
setContentView(R.layout.activity_main);
|
49
|
+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
50
|
+
setSupportActionBar(toolbar);
|
51
|
+
|
52
|
+
numberView1 = findViewById(R.id.numberView1);
|
53
|
+
|
54
|
+
SeekBar seekBar1 = findViewById(R.id.seekBar1);
|
55
|
+
|
56
|
+
seekBar1.setProgress(0);
|
57
|
+
seekBar1.setMax(100);
|
58
|
+
|
59
|
+
seekBar1.setOnSeekBarChangeListener(
|
60
|
+
new SeekBar.OnSeekBarChangeListener() {
|
61
|
+
@Override
|
62
|
+
public void onProgressChanged(
|
63
|
+
SeekBar seekBar1, int progress, boolean fromUser) {
|
64
|
+
String str = String.format(Locale.US, "%d %%",progress);
|
65
|
+
numberView1.setText(str);
|
66
|
+
}
|
67
|
+
@Override
|
68
|
+
public void onStartTrackingTouch(SeekBar seekBar1) {
|
69
|
+
}
|
70
|
+
public void onStopTrackingTouch(SeekBar seekBar1) {
|
71
|
+
|
72
|
+
}
|
73
|
+
}
|
74
|
+
);
|
75
|
+
|
76
|
+
/*長すぎたので省略しますが、6個同じようなことが書いてあります
|
77
|
+
これは後からボタンを押したときにSeekBarとかNumberViewとかをセットで増やすようにする予定だからです
|
18
|
-
|
78
|
+
*/
|
79
|
+
|
80
|
+
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
81
|
+
fab.setOnClickListener(new View.OnClickListener() {
|
82
|
+
@Override
|
83
|
+
public void onClick(View view) {
|
84
|
+
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
85
|
+
.setAction("Action", null).show();
|
86
|
+
}
|
87
|
+
});
|
88
|
+
|
89
|
+
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
90
|
+
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
91
|
+
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
92
|
+
drawer.addDrawerListener(toggle);
|
93
|
+
toggle.syncState();
|
94
|
+
|
95
|
+
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
96
|
+
navigationView.setNavigationItemSelectedListener(this);
|
97
|
+
}
|
98
|
+
|
99
|
+
@Override
|
100
|
+
public void onBackPressed() {
|
101
|
+
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
102
|
+
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
103
|
+
drawer.closeDrawer(GravityCompat.START);
|
104
|
+
} else {
|
105
|
+
super.onBackPressed();
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
@Override
|
110
|
+
public boolean onCreateOptionsMenu(Menu menu) {
|
111
|
+
// Inflate the menu; this adds items to the action bar if it is present.
|
112
|
+
getMenuInflater().inflate(R.menu.main, menu);
|
113
|
+
return true;
|
114
|
+
}
|
115
|
+
|
116
|
+
@Override
|
117
|
+
public boolean onOptionsItemSelected(MenuItem item) {
|
118
|
+
|
119
|
+
int id = item.getItemId();
|
120
|
+
|
121
|
+
//noinspection SimplifiableIfStatement
|
122
|
+
if (id == R.id.action_settings) {
|
123
|
+
return true;
|
124
|
+
}
|
125
|
+
|
126
|
+
return super.onOptionsItemSelected(item);
|
127
|
+
}
|
128
|
+
|
129
|
+
@SuppressWarnings("StatementWithEmptyBody")
|
130
|
+
@Override
|
131
|
+
public boolean onNavigationItemSelected(MenuItem item) {
|
132
|
+
// Handle navigation view item clicks here.
|
133
|
+
int id = item.getItemId();
|
134
|
+
|
135
|
+
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
136
|
+
drawer.closeDrawer(GravityCompat.START);
|
137
|
+
return true;
|
138
|
+
|
139
|
+
}
|
140
|
+
}
|
19
141
|
```
|
20
142
|
|
21
143
|
### 試したこと
|
@@ -24,4 +146,90 @@
|
|
24
146
|
|
25
147
|
### 補足情報(FW/ツールのバージョンなど)
|
26
148
|
|
149
|
+
ソースコードに載せたのはJavaのMainActivityです
|
27
|
-
|
150
|
+
変えたのはほとんどレイアウトとかだけです
|
151
|
+
|
152
|
+
Content_main.xmlはこちらになります
|
153
|
+
|
154
|
+
<?xml version="1.0" encoding="utf-8"?>
|
155
|
+
<android.support.constraint.ConstraintLayout 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
|
+
android:layout_width="match_parent"
|
159
|
+
android:layout_height="match_parent"
|
160
|
+
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
161
|
+
tools:context=".MainActivity"
|
162
|
+
tools:showIn="@layout/app_bar_main">
|
163
|
+
|
164
|
+
<ScrollView
|
165
|
+
android:id="@+id/ScrollView"
|
166
|
+
android:layout_width="fill_parent"
|
167
|
+
android:layout_height="fill_parent">
|
168
|
+
<LinearLayout
|
169
|
+
android:id="@+id/LinearLayout"
|
170
|
+
android:orientation="vertical"
|
171
|
+
android:layout_width="fill_parent"
|
172
|
+
android:layout_height="fill_parent">
|
173
|
+
|
174
|
+
<LinearLayout
|
175
|
+
android:layout_width="match_parent"
|
176
|
+
android:layout_height="match_parent"
|
177
|
+
android:orientation="vertical">
|
178
|
+
|
179
|
+
<TextView
|
180
|
+
android:id="@+id/textView1"
|
181
|
+
android:layout_width="wrap_content"
|
182
|
+
android:layout_height="wrap_content"
|
183
|
+
android:layout_marginStart="16dp"
|
184
|
+
android:layout_marginLeft="16dp"
|
185
|
+
android:layout_marginTop="5dp"
|
186
|
+
android:layout_marginEnd="0dp"
|
187
|
+
android:layout_marginRight="0dp"
|
188
|
+
android:text="元気!"
|
189
|
+
android:textSize="24sp"
|
190
|
+
app:layout_constraintBottom_toTopOf="@+id/seekBar2"
|
191
|
+
app:layout_constraintEnd_toEndOf="parent"
|
192
|
+
app:layout_constraintHorizontal_bias="0.0"
|
193
|
+
app:layout_constraintStart_toStartOf="parent"
|
194
|
+
app:layout_constraintTop_toTopOf="parent" />
|
195
|
+
|
196
|
+
<TextView
|
197
|
+
android:id="@+id/numberView1"
|
198
|
+
android:layout_width="wrap_content"
|
199
|
+
android:layout_height="wrap_content"
|
200
|
+
android:layout_marginStart="150dp"
|
201
|
+
android:layout_marginLeft="120dp"
|
202
|
+
android:layout_marginTop="0dp"
|
203
|
+
android:layout_marginEnd="0dp"
|
204
|
+
android:layout_marginRight="0dp"
|
205
|
+
android:layout_marginBottom="0dp"
|
206
|
+
android:text=""
|
207
|
+
android:textSize="18sp"
|
208
|
+
app:layout_constraintBottom_toTopOf="@+id/seekBar1"
|
209
|
+
app:layout_constraintEnd_toEndOf="parent"
|
210
|
+
app:layout_constraintHorizontal_bias="0.491"
|
211
|
+
app:layout_constraintStart_toEndOf="@+id/textView1"
|
212
|
+
app:layout_constraintTop_toTopOf="parent"
|
213
|
+
app:layout_constraintVertical_bias="0.544" />
|
214
|
+
|
215
|
+
<SeekBar
|
216
|
+
android:id="@+id/seekBar1"
|
217
|
+
android:layout_width="347dp"
|
218
|
+
android:layout_height="44dp"
|
219
|
+
android:layout_marginStart="18dp"
|
220
|
+
android:layout_marginLeft="18dp"
|
221
|
+
android:layout_marginTop="0dp"
|
222
|
+
android:layout_marginEnd="0dp"
|
223
|
+
android:layout_marginRight="0dp"
|
224
|
+
app:layout_constraintBottom_toTopOf="@+id/textView1"
|
225
|
+
app:layout_constraintEnd_toEndOf="parent"
|
226
|
+
app:layout_constraintStart_toStartOf="parent"
|
227
|
+
app:layout_constraintTop_toBottomOf="@+id/textView1" />
|
228
|
+
|
229
|
+
</LinearLayout>
|
230
|
+
|
231
|
+
<!--これも同じように6個ぐらいあります。-->
|
232
|
+
|
233
|
+
</LinearLayout>
|
234
|
+
</ScrollView>
|
235
|
+
</android.support.constraint.ConstraintLayout>
|