【问题标题】:Display tabs at the bottom in Android在 Android 的底部显示标签
【发布时间】:2013-07-13 17:36:05
【问题描述】:

首先抱歉!我真的尝试过使用 StackOverFlow 来找到这个问题的答案。我在这里看到了一个答案 -Android: Tabs at the BOTTOM 其他人正在理解,但我无法理解该解决方案。

我删减的 XML 代码是这样的

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<TabHost
    android:id="@+id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        android:orientation="vertical"
        android:padding="5dp" >

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

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

                <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >
                </FrameLayout>

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="-5px"
                    android:layout_weight="0"
                    android:background="#ffff0000" >
                </TabWidget>
            </LinearLayout>

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

            <LinearLayout
                android:id="@+id/tab3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >
            </LinearLayout>
        </FrameLayout>
    </LinearLayout>
</TabHost>

如何让选项卡的选择显示在底部?非常感谢

【问题讨论】:

标签: android xml tags


【解决方案1】:

为此,您必须使用RelativeLayout 而不是LinearLayout,而不是在TabWidget 中使用android:layout_alignParentBottom="true" 属性

改变

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

            <FrameLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </FrameLayout>

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="-5px"
                android:layout_weight="0"
                android:background="#ffff0000" >
            </TabWidget>
        </LinearLayout>

收件人

              <RelativeLayout
                android:id="@+id/tab1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                 >

                <FrameLayout
                    android:layout_alignParentTop="true"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </FrameLayout>

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:layout_marginBottom="-5px"
                    android:layout_weight="0"
                    android:layout_alignParentBottom="true"
                    android:background="#ffff0000" >
                </TabWidget>

            </RelativeLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-14
    • 1970-01-01
    • 2019-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多