1

私はAndroidが初めてで、2つのタブウィジェットでタブホストを作成していましたが、すべてうまくいき、2つのタブで2つの異なるアクティビティを表示しています.しかし、問題は、2つの異なるタブに指定しているテキストが下に来ていることです.アプリを実行しています。以下に、理解のためにスクリーンショットを入れています

スクリーンショット: ここに画像の説明を入力

テキストは赤でマークされているので、そのテキストを中央に揃える方法はありますか。もう1つ、ユーザーのクリックのさまざまな状態に描画可能な画像を使用しています。助けてくれてありがとう。

タブホストの xml ファイル

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <include layout="@layout/top_portion_layout"/>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textAlignment="center"
           >
        </TabWidget>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#808080">
            </FrameLayout>

    </LinearLayout>
</TabHost>

この部分は別のレイアウトで、2 つのボタンがすべて同期され、このレイアウトに含まれています。

4

1 に答える 1

0

にもかかわらず

android:textAlignment="center"

あなたが使用する必要があります

android:gravity="center"
android:layout_gravity="center_vertical"

tab_host要素の内部

于 2013-02-23T12:40:37.410 に答える