質問編集履歴
3
Layoutソースを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -223,3 +223,233 @@
|
|
223
223
|
```
|
224
224
|
|
225
225
|
このコードで、下の写真のようなtabを作りたいのですが、上のようになってしまします。どうしてでしょう?
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
レイアウトはこちらです。
|
232
|
+
|
233
|
+
res/layout/activity_main.xml
|
234
|
+
|
235
|
+
```lang-ja
|
236
|
+
|
237
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
238
|
+
|
239
|
+
xmlns:tools="http://schemas.android.com/tools"
|
240
|
+
|
241
|
+
android:layout_width="match_parent"
|
242
|
+
|
243
|
+
android:layout_height="match_parent"
|
244
|
+
|
245
|
+
android:orientation="vertical"
|
246
|
+
|
247
|
+
tools:context=".MainActivity">
|
248
|
+
|
249
|
+
<TabHost
|
250
|
+
|
251
|
+
android:id="@android:id/tabhost"
|
252
|
+
|
253
|
+
android:layout_width="match_parent"
|
254
|
+
|
255
|
+
android:layout_height="wrap_content"
|
256
|
+
|
257
|
+
android:background="?android:attr/colorPrimary">
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
<TabWidget
|
262
|
+
|
263
|
+
android:id="@android:id/tabs"
|
264
|
+
|
265
|
+
android:layout_width="match_parent"
|
266
|
+
|
267
|
+
android:layout_height="wrap_content" />
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
<FrameLayout
|
272
|
+
|
273
|
+
android:id="@android:id/tabcontent"
|
274
|
+
|
275
|
+
android:layout_width="0dp"
|
276
|
+
|
277
|
+
android:layout_height="0dp" />
|
278
|
+
|
279
|
+
<View
|
280
|
+
|
281
|
+
android:id="@+id/indicator"
|
282
|
+
|
283
|
+
android:layout_width="match_parent"
|
284
|
+
|
285
|
+
android:layout_height="2dp"
|
286
|
+
|
287
|
+
android:layout_gravity="bottom"
|
288
|
+
|
289
|
+
android:background="?android:attr/colorControlActivated" />
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
</TabHost>
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
<android.support.v4.view.ViewPager
|
298
|
+
|
299
|
+
android:id="@+id/pager"
|
300
|
+
|
301
|
+
android:layout_width="match_parent"
|
302
|
+
|
303
|
+
android:layout_height="match_parent">
|
304
|
+
|
305
|
+
</android.support.v4.view.ViewPager>
|
306
|
+
|
307
|
+
</LinearLayout>
|
308
|
+
|
309
|
+
```
|
310
|
+
|
311
|
+
res/layout/left_view_fragment.xml
|
312
|
+
|
313
|
+
```lang-j
|
314
|
+
|
315
|
+
<?xml version="1.0" encoding="utf-8"?>
|
316
|
+
|
317
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
318
|
+
|
319
|
+
android:layout_width="match_parent"
|
320
|
+
|
321
|
+
android:layout_height="match_parent"
|
322
|
+
|
323
|
+
android:orientation="vertical" >
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
<TextView
|
328
|
+
|
329
|
+
android:layout_width="wrap_content"
|
330
|
+
|
331
|
+
android:layout_height="wrap_content"
|
332
|
+
|
333
|
+
android:textSize="30sp"
|
334
|
+
|
335
|
+
android:text="Left Fragment" />
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
</LinearLayout>
|
340
|
+
|
341
|
+
```
|
342
|
+
|
343
|
+
res/layout/center_view_fragment
|
344
|
+
|
345
|
+
```lang-j
|
346
|
+
|
347
|
+
<?xml version="1.0" encoding="utf-8"?>
|
348
|
+
|
349
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
350
|
+
|
351
|
+
android:layout_width="match_parent"
|
352
|
+
|
353
|
+
android:layout_height="match_parent"
|
354
|
+
|
355
|
+
android:orientation="vertical" >
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
<TextView
|
360
|
+
|
361
|
+
android:layout_width="wrap_content"
|
362
|
+
|
363
|
+
android:layout_height="wrap_content"
|
364
|
+
|
365
|
+
android:textSize="30sp"
|
366
|
+
|
367
|
+
android:text="Center Fragment" />
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
</LinearLayout>
|
372
|
+
|
373
|
+
```
|
374
|
+
|
375
|
+
res/layout/right_view_fragment.xml
|
376
|
+
|
377
|
+
```lang-j
|
378
|
+
|
379
|
+
<?xml version="1.0" encoding="utf-8"?>
|
380
|
+
|
381
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
382
|
+
|
383
|
+
android:layout_width="match_parent"
|
384
|
+
|
385
|
+
android:layout_height="match_parent"
|
386
|
+
|
387
|
+
android:orientation="vertical" >
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
<TextView
|
392
|
+
|
393
|
+
android:layout_width="wrap_content"
|
394
|
+
|
395
|
+
android:layout_height="wrap_content"
|
396
|
+
|
397
|
+
android:textSize="30sp"
|
398
|
+
|
399
|
+
android:text="Right Fragment" />
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
</LinearLayout>
|
404
|
+
|
405
|
+
```
|
406
|
+
|
407
|
+
res/layout/tab_widget
|
408
|
+
|
409
|
+
```lang-ja
|
410
|
+
|
411
|
+
<?xml version="1.0" encoding="utf-8"?>
|
412
|
+
|
413
|
+
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
414
|
+
|
415
|
+
xmlns:tools="http://schemas.android.com/tools"
|
416
|
+
|
417
|
+
android:layout_width="0dp"
|
418
|
+
|
419
|
+
android:layout_height="match_parent"
|
420
|
+
|
421
|
+
android:layout_weight="1"
|
422
|
+
|
423
|
+
android:gravity="bottom|center_horizontal"
|
424
|
+
|
425
|
+
android:paddingBottom="16dp"
|
426
|
+
|
427
|
+
android:textColor="@color/tab_widget_text"
|
428
|
+
|
429
|
+
android:textSize="14sp"
|
430
|
+
|
431
|
+
tools:layout_width="match_parent"
|
432
|
+
|
433
|
+
tools:text="group 1 ITEM TWO" />
|
434
|
+
|
435
|
+
```
|
436
|
+
|
437
|
+
res/color/tab_widget_text.xml
|
438
|
+
|
439
|
+
```lang-j
|
440
|
+
|
441
|
+
<?xml version="1.0" encoding="utf-8"?>
|
442
|
+
|
443
|
+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
444
|
+
|
445
|
+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
446
|
+
|
447
|
+
<item android:color="#FFFFFFFF" android:state_selected="true" />
|
448
|
+
|
449
|
+
<item android:color="#99FFFFFF" />
|
450
|
+
|
451
|
+
</selector>
|
452
|
+
|
453
|
+
</selector>
|
454
|
+
|
455
|
+
```
|
2
写真追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
![![![![イメージ][WIDTH:320](5d3586fe044f641329dec2799c7f5003.png)][WIDTH:600](bf37c84f28a48398dd0b09cd13dd5ad7.png)説明][WIDTH:320](8dcb5303c1a10141ebf586c05be1967e.png)説明][WIDTH:320](7fab3e1edb0d3cad98561dc0fd78ce66.png)][WIDTH:320](18f54fe87b5edfa6646564e9356af8b9.png)```lang-java
|
1
|
+
![イメージ説明][WIDTH:600](50f7295fa4943abc8e70c2e12125b93f.png)![![![![イメージ][WIDTH:320](5d3586fe044f641329dec2799c7f5003.png)][WIDTH:600](bf37c84f28a48398dd0b09cd13dd5ad7.png)説明][WIDTH:320](8dcb5303c1a10141ebf586c05be1967e.png)説明][WIDTH:320](7fab3e1edb0d3cad98561dc0fd78ce66.png)][WIDTH:320](18f54fe87b5edfa6646564e9356af8b9.png)```lang-java
|
2
2
|
|
3
3
|
import android.os.Bundle;
|
4
4
|
|
@@ -222,4 +222,4 @@
|
|
222
222
|
|
223
223
|
```
|
224
224
|
|
225
|
-
このコードで、
|
225
|
+
このコードで、下の写真のようなtabを作りたいのですが、上のようになってしまします。どうしてでしょう?
|
1
写真追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
```lang-java
|
1
|
+
![![![![イメージ][WIDTH:320](5d3586fe044f641329dec2799c7f5003.png)][WIDTH:600](bf37c84f28a48398dd0b09cd13dd5ad7.png)説明][WIDTH:320](8dcb5303c1a10141ebf586c05be1967e.png)説明][WIDTH:320](7fab3e1edb0d3cad98561dc0fd78ce66.png)][WIDTH:320](18f54fe87b5edfa6646564e9356af8b9.png)```lang-java
|
2
2
|
|
3
3
|
import android.os.Bundle;
|
4
4
|
|