14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

タブをフッターに作りたいときはxmlのTabWidgetの位置を変える

Posted at

タブバーを作成する時にTabWidgetの位置を変えることでタブの表示位置をViewの上部でも下部でも簡単に変えられます。

上部

<?xml version="1.0" encoding="utf-8"?>
<TabHost                       
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_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" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" >

            <LinearLayout
                android:id="@+id/first_content"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                <WebView
                    android:id="@+id/wvHome"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
            </LinearLayout>
            <LinearLayout
                android:id="@+id/second_content"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

                <WebView
                    android:id="@+id/wvSearch"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
            </LinearLayout>
      </FrameLayout>
    </LinearLayout>
</TabHost>

下部

<?xml version="1.0" encoding="utf-8"?>

<TabHost       
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" >

            <LinearLayout
                android:id="@+id/first_content"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                <WebView
                    android:id="@+id/wvHome"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
            </LinearLayout>
            <LinearLayout
                android:id="@+id/second_content"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

                <WebView
                    android:id="@+id/wvSearch"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
            </LinearLayout>
        </FrameLayout>
   <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
   </LinearLayout>
</TabHost>
14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?