如何在此布局中添加页脚栏?

时间:2015-01-19 02:27:06

标签: android android-layout android-linearlayout

我的布局如下所示

Image TabName1 TabName2 TabName3 EditText

< --------------------标签内容----------------------&gt ;

我需要在标签内容下方添加一个页脚栏,如下图所示

Image TabName1 TabName2 TabName3 EditText

< --------------------标签内容----------------------&gt ;

< -------------------- Footer ------------------------ ------>

这是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:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="5dp" >

            <ImageView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/ic_launcher" />

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="#F0F0F0"
                android:showDividers="none" />

            <EditText
                android:id="@+id/qsearch"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ellipsize="end"
                android:imeOptions="actionSearch|flagNoExtractUi"
                android:inputType="text"
                android:lines="1"
                android:maxLines="1"
                android:scrollHorizontally="true"
                android:singleLine="true"
                android:text="sdfsf" >

                <requestFocus />
            </EditText>
        </LinearLayout>

        <RelativeLayout
            android:id="@+id/content"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
             >

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="0dp" />

        </RelativeLayout>
    </LinearLayout>

</TabHost>

我尝试使用android:layout_alignParentBottom添加LinearLayout但它不起作用。

2 个答案:

答案 0 :(得分:0)

你可以使用LinearLayout权重来实现这一点,试试这个:

<?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:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:padding="5dp" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/logo1" />

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#F0F0F0"
            android:showDividers="none" />

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

        <EditText
            android:id="@+id/qsearch"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:imeOptions="actionSearch|flagNoExtractUi"
            android:inputType="text"
            android:scrollHorizontally="true"
            android:singleLine="true" >

            <requestFocus />
        </EditText>

        <LinearLayout
            android:id="@+id/footer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </LinearLayout>
    </LinearLayout>

</TabHost>

答案 1 :(得分:0)

好的,我通过在内容的RelativeLayout中添加LinearLayout来解决它。

        <LinearLayout
            android:id="@+id/footer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            android:background="#FFFFFF"
            android:orientation="horizontal"
            android:layout_alignParentBottom="true">

        </LinearLayout>            
相关问题