Android TabHost内部的线性布局仅显示一个元素
我的android应用程序中有此布局文件:Android TabHost内部的线性布局仅显示一个元素,android,tabview,android-linearlayout,Android,Tabview,Android Linearlayout,我的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_pare
<?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”
只显示它包含的一个元素(上面代码中的文本视图)。如果我删除文本视图,它会显示编辑文本
如何使它同时显示(以及更多)元素?那里有很多多余的布局,但看起来真正的问题是
layoutSearch
是一个垂直线性布局,有两个子元素,但第一个子元素的高度设置为fill\u parent
,因此您自然不会看到第二个子元素。尝试将其高度设置为0px
,但给它一个布局权重为1
,它应该可以扩展到它下面的EditText
没有占用的所有可用空间。我知道它看起来像是在复制一个iPhone应用程序,但在我看来,这更容易看到屏幕的其余部分,当它们在上面时,你的手覆盖了整个屏幕。你是对的,也许我应该把它向上移动,我会考虑它。我将高度改为包裹内容
,现在它工作了。还有一个问题:你说有很多多余的布局。。你建议我怎样做才能更好?谢谢你的帮助!哦,我的意思是相对于你的问题,所有关于layoutSearch
的容器内容都不相关。如果你愿意的话,你可以用一个相对论来把事情弄平一点。啊,对了,我不知道是哪个部分导致了问题,这就是为什么我把所有的东西都贴出来了。无论如何,再次感谢你的帮助!