0

アプリケーションにタブホストを追加しようとしています。これまでのところ、一部は完了しています (何らかの理由でコンテンツが表示されませんが、後で修正できません)。しかし、(別の 3 つのコンテナーのように追加して狂ったようにマージすることなく)、タブホストが画面上であまり多くのスペースを占有しないようにすること、またはマージンが使用されていない限り、画面全体を占有する必要があることを確認することは可能ですか?

私が持っている現在の方法

| | _ _ _ _ _ _ _ _ _ _ _ _
| | ヘッダー
|タブバー
|タブコンテンツ
|タブコンテンツ
|
__ _ __ _ _ __ _ _ __ _ _ _ _

しかし中心にある

私が望む方法

| | _ _ _ _ _ _ _ _ _ _ _ _
| | ヘッダー
|タブバー | 写真
|タブコンテンツ | 写真
|タブコンテンツ | 写真
|
__ _ __ _ _ __ _ _ __ _ _ _ _

tha a pic は、右側のスペース全体を占める写真です。

タブホストを操作するだけで、このようなことは可能ですか? または、タブホストはフルスクリーンのものですか。

4

1 に答える 1

0

私はそれを考え出した。以前に私のxmlで奇妙な作業がありましたが、可能です。私はLinearLayoutを使用しており、右側の写真はその重みが1です。次に、コンテンツをラップする高さと幅のみを許可するようにタブホストを設定した方法を以下に示します。

 <TabHost
            android:id="@android:id/tabhost"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:layout_marginTop="125dp" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_gravity="center_vertical"
                android:orientation="vertical" >

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal" >

                </TabWidget>

                <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:visibility="gone" />

                <FrameLayout
                    android:id="@+android:id/realtabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" />

            </LinearLayout>
        </TabHost>

これは私にとってはうまくいきました。他の誰かに役立つことを願っています。

于 2013-02-19T15:51:09.863 に答える