独自のビューを定義する必要があります。
tabHost.newTabSpec("tab1")
.setIndicator(prepareTabView(this, "title"))
.setContent(intent);
、あなたがテキストのサイズ、ここでtv.setTextSizeを変更することができます(20) "
public static View prepareTabView(Context context, String text) {
View view = LayoutInflater.from(context).inflate(
R.layout.tab_indicator, null);
TextView tv = (TextView) view.findViewById(R.id.tabIndicatorTextView);
tv.setText(text);
return view;
}
tab_indicator.xmlはあなたがここにテキストサイズもアンドロイド変更することができます。TEXTSIZE =" 20dipを"ここで背景色を設定することが可能であるアンドロイド:背景=" @カラー/ back_color_selector_tab」
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fakeNativeTabLayout" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center"
android:orientation="vertical" android:background="@color/back_color_selector_tab">
<!-- You can even define an Icon here (dont forget to set a custom icon
in your code for each Tab): <ImageView android:id="@+id/fakeNativeTabImageView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/icon" /> -->
<TextView android:id="@+id/tabIndicatorTextView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Tab" android:ellipsize="marquee" />
</LinearLayout>
back_color_selector_tab.xmlは、さまざまな州の背景色が自動的に変更されるxmlです。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/state_orange" />
<item android:state_selected="true" android:drawable="@drawable/background05" /> <!-- focused -->
<item android:drawable="@drawable/background04" /> <!-- default -->
</selector>
state_orange.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/orange" />
</shape>
コードの各部分が何をしているのか説明できますか? 私はそれがどのようにAとB ... – Belgi
このサンプルではすべてのものがあなたの手にあり、tab_indicator.xmlファイルの設計に依存して – breceivemail
私はそのコードを使用してみました。 prepareTabViewそれはR.layout.tab_indicatorを認識しません B.ヘックストリプレット(#007FFFなど)で色を選択できますか? C. はエラーです... –
Belgi