1

タブごとにタブアイコンとテキストの両方を使用するアプリケーションにタブホストがあります。私の人生では、タブ全体を埋めるのではなく、テキストの上にアイコンを中央に配置することはできません。私の検索では、他の人がアイコンを取得してタブ全体を埋めようとしているだけでした。私が見た他のすべての例には、テキストの上にアイコンがあります。

タブを設定して追加する方法は次のとおりです。

tabs = (TabHost) this.findViewById(R.id.conference_tabhost);
tabs.setOnTabChangedListener(this);
tabs.setup();

TabSpec tspecMenu = tabs.newTabSpec(tab_tag_menu);
tspecMenu.setIndicator("Menu", getResources().getDrawable(R.drawable.ic_tab_menu));
tspecMenu.setContent(R.id.tab_menu_view);
tabs.addTab(tspecMenu);

これが私のレイアウトの始まりです:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/conference_tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </TabWidget>
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
4

0 に答える 0