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"そこに含まれる要素の1つだけが表示されることです(上記のコードのテキストビュー)。textviewを削除すると、EditTextが表示されます。

両方(およびそれ以上)の要素を表示するにはどうすればよいですか?

4

1 に答える 1

1

そこには余分なレイアウトがたくさんありますが、本当の問題はlayoutSearch2つの子を持つ垂直LinearLayoutであるように見えますが、最初の子の高さはに設定されてfill_parentいるため、当然、2番目の子は表示されません。高さをに設定してみてください。0pxただし、の値を指定するlayout_weightと、その下で1使用されていない使用可能なスペースをすべて使用できるように拡張されEditTextます。

于 2011-04-26T16:07:36.987 に答える