Android 两个列表视图上方的文本视图
我想在我的两个列表视图上方有一个文本视图。这是我的xml代码:Android 两个列表视图上方的文本视图,android,xml,listview,layout,textview,Android,Xml,Listview,Layout,Textview,我想在我的两个列表视图上方有一个文本视图。这是我的xml代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:baselineAligned="false" android:orientation="horizontal" android:layout_height="match_parent" android:layout_width="m
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false"
android:orientation="horizontal"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test" />
<LinearLayout
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_width="match_parent"
>
<ListView
android:id="@+id/leftView"
android:layout_height="match_parent"
android:layout_width="match_parent">
</ListView>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="@+id/rightView"
android:layout_height="match_parent"
android:layout_width="match_parent">
</ListView>
</LinearLayout>
</LinearLayout>
在我添加TextView之前,一切都很顺利。现在只有TextView可见,两个ListView不再显示
编辑:我希望列表视图仍然相邻(一左一右)。将
线性布局的方向更改为垂直
android:orientation="vertical"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test" />
<LinearLayout
android:orientation="horizontal"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:layout_weight="1"
android:id="@+id/rightView"
android:layout_height="match_parent"
android:layout_width="0dip">
</ListView>
<ListView
android:layout_weight="1"
android:id="@+id/leftView"
android:layout_height="match_parent"
android:layout_width="0dip">
</ListView>
</LinearLayout>
</LinearLayout>
android:orientation=“垂直”
谢谢。现在将显示列表视图。但是一个比另一个低。我想要一个左边,另一个右边。谢谢。这很有效。但我得到一个警告:“嵌套权重对性能有害”。请从LinearLayout中删除权重属性。