【发布时间】:2021-05-22 03:23:16
【问题描述】:
正如标题所说,我想在显示地址的列表视图中添加一些标题。似乎我基本上可以在页面上显示的列表视图或标题之间进行选择。 在下图中,我的标题(4 个文本视图)采用线性布局。当线性布局在我的代码中时,我的列表视图不显示
当我删除我的线性布局时,我的列表视图出现了!我的代码如下:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/frameLayoutParent"
android:background="@android:color/holo_green_dark">
<android.support.v4.widget.SwipeRefreshLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/swipeLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/headerLinearLayout">
<TextView
android:text="Address Line"
android:id="@+id/headerAddressLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="25"
android:gravity="center_horizontal"
android:textSize="16sp"/>
<TextView
android:text="City"
android:id="@+id/headerCity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="25"
android:gravity="center_horizontal"
android:textSize="16sp"/>
<TextView
android:text="State"
android:id="@+id/headerState"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="25"
android:gravity="center_horizontal"
android:textSize="16sp"/>
<TextView
android:text="Zip Code"
android:id="@+id/headerZipCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="25"
android:gravity="center_horizontal"
android:textSize="16sp"/>
</LinearLayout>
<ListView
android:paddingTop="40dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView"/>
</android.support.v4.widget.SwipeRefreshLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editSearch"
android:hint="Search ZipCodes"
android:textColor="#000"
android:editable="false"/>
</FrameLayout>
我试过了:
- 将列表视图的位置切换到线性布局上方
- 添加一个额外的线性布局以包含两个标题,然后是列表视图
- 在列表视图正上方添加 2dp 高度视图
- 弄乱元素的高度,尝试 wrap_content、match_parent 的不同组合,并设置精确的高度
感谢您的帮助!
【问题讨论】:
标签: android xaml listview xamarin layout