SortableTableView не переносит высоту в свое содержимое
Я использую 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
высота макета. Любая поддержка будет очень признательна.
1 ответ
Решение
Я также обнаружил эту проблему, которая, похоже, что высота по умолчанию уже 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>