0

我的 android 应用程序中有这个布局文件:

<?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:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1">
            <TextView 
                android:id="@+id/textview1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" 
                android:text="this is a tab" />
            <TextView 
                android:id="@+id/textview2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" 
                android:text="this is another tab" />
            <LinearLayout
                android:id="@+id/layoutSearch"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">
                <TextView
                    android:id="@+id/textview4"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" 
                    android:text="Search here" />
                <EditText
                    android:id="@+id/editSearch"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

            </LinearLayout>
        </FrameLayout>
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"/>
    </LinearLayout>
</TabHost>

我的问题是LinearLayout android:id="@+id/layoutSearch"它只显示它包含的元素之一(文本视图,在上面的代码中)如果我删除文本视图,它会显示 EditText。

如何让它显示两个(以及更多)元素?

4

1 回答 1

1

那里有很多多余的布局,但看起来真正的问题是layoutSearch有两个孩子的垂直 LinearLayout,但第一个孩子的高度设置为fill_parent,所以你自然看不到第二个。尝试将它的高度设置为0px但给它一个layout_weight1它应该扩展以占用它下面未占用的所有可用空间EditText

于 2011-04-26T16:07:36.987 回答