0

我使用SortableTableView作为我的表格视图,但在组件正下方包含一个 TextView 时遇到了问题。

在此处输入图像描述

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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">
    <de.codecrafters.tableview.SortableTableView
       android:id="@+id/tableView"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       app:tableView_columnCount="4"
       app:tableView_headerElevation="10" />
   <TextView
       android:id="@+id/txtSummaryRecords"
       android:textAppearance="?android:attr/textAppearanceMedium"
       android:text="Summary details goes here"
       android:layout_below="@+id/tableView"
       android:gravity="center_horizontal"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:textColor="?android:attr/colorError" />
</RelativeLayout>

但是,当我将静态值添加到如下高度时,它会显示在表格的正下方。

<de.codecrafters.tableview.SortableTableView
     android:id="@+id/tableView"
     android:layout_width="match_parent"
     android:layout_height="450dp" <--included value
     app:tableView_columnCount="4"
     app:tableView_headerElevation="10" />

结果:

在此处输入图像描述

我尝试设置android:layout_height=match_parent没有区别。看起来 SortableTableView 填充了整个屏幕,而不考虑wrap_content布局高度。任何支持将不胜感激。

4

1 回答 1

0

我也发现了这个问题,好像默认高度已经是match_parent.

如果您希望 TextView 位于底部,而 SortableTableView 位于其上方。您可以像下面这样作为解决方法。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  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">

  <de.codecrafters.tableview.SortableTableView
    android:id="@+id/tableView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/toolbar"
    android:layout_above="@+id/txtSummaryRecords"
    app:tableView_columnCount="4"
    app:tableView_headerElevation="10"
    app:tableView_headerColor="@color/primary" />
  <TextView
    android:id="@+id/txtSummaryRecords"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Summary details goes here"
    android:layout_alignParentBottom="true"
    android:gravity="center_horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="?android:attr/colorError" />
</RelativeLayout>
于 2020-05-20T07:07:49.757 回答