回答編集履歴

1

サンプルコード追加

2015/06/16 20:03

投稿

terushu
terushu

スコア358

test CHANGED
@@ -7,3 +7,59 @@
7
7
 
8
8
 
9
9
  とりあえず文字色だけ変更するのであれば、setTextした内容の文字列を持っているTextViewを探す、という方式を採るのが良いと思います。
10
+
11
+
12
+
13
+ もう少しソフトな方法ですと、setIndicatorで独自のViewを組み込むというものです。
14
+
15
+ 例えば、
16
+
17
+ ```lang-xml
18
+
19
+ <?xml version="1.0" encoding="utf-8"?>
20
+
21
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
22
+
23
+ android:layout_width="match_parent"
24
+
25
+ android:layout_height="match_parent"
26
+
27
+ android:orientation="vertical">
28
+
29
+
30
+
31
+ <TextView
32
+
33
+ android:id="@+id/text"
34
+
35
+ android:layout_width="match_parent"
36
+
37
+ android:layout_height="wrap_content"
38
+
39
+ android:layout_gravity="center_vertical|center_horizontal"
40
+
41
+ android:textColor="色指定"/>
42
+
43
+ </LinearLayout>
44
+
45
+ ```
46
+
47
+ のようなレイアウトを用意します。
48
+
49
+ これを、
50
+
51
+ ```lang-java
52
+
53
+ TabHost.TabSpec tabSpec = tabHost.newTabSpec("TabTag");
54
+
55
+ LinearLayout tabLayout = (LinearLayout) inflater.inflate(R.layout.tab, null);
56
+
57
+ TextView tabTextView = (TextView) tabLayout.findViewById(R.id.text);
58
+
59
+ tabTextView.setText("タブ文字列");
60
+
61
+ tabSpec.setIndicator(tabLayout);
62
+
63
+ ```
64
+
65
+ のようにすれば、文字色以外も文字表示部分をカスタマイズできます。