私は、いくつかのタブを持つ GUI で構成される小さなプロジェクトに取り組んできました。私はフラグメントの概念にまったく慣れていませんが、Android タブのランドスケープ内でのベスト プラクティスのようです。3 つのタブを切り替える単純なタブ アプリをコーディングすることができました。
唯一の問題は、タブを画面の下部に配置しようとしたときです。それらが一番下にあるとき、タブ ウィジェットはコンテナー (この場合はフレーム レイアウト) をカバーするため、何も起こらず、さまざまなタブをクリックしても画面は同じままです。
次の XML レイアウトは、適切なバージョン (タブが画面の上部にある) を表しています。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost
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"
>
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<FrameLayout
android:id="@+android:id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</TabHost>
</LinearLayout>
次の XML レイアウトは、タブが画面の下部にあるときに機能しないバージョンを表しています。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
/>
<FrameLayout
android:id="@+android:id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
/>
</RelativeLayout>
</TabHost>
</LinearLayout>
私はlayourをrelativelayoutに変更し、このコマンドを追加しました: android:layout_alignParentBottom="true" をtabwidgetに追加しました。この問題をどのように分類できるかについて、別のアイデアを持っている人はいますか? 前もって感謝します。