ISchwarz23 / SortableTableView

An Android library containing a simple TableView and an advanced SortableTableView providing a lot of customisation possibilities to fit all needs.
Apache License 2.0
1.05k stars 237 forks source link

Problem in showing list of tables in Recyclerview #170

Open yubarajoli77 opened 5 years ago

yubarajoli77 commented 5 years ago

I tried to show the list of tables in recycler view using custom design for row, all goes fine but table only show 4 rows including header i.e all rows are not included when I use layout_height to match_parent. But they are visible when I give static value like 200dp. How to include my all dynamic rows no matter how many rows are there. Here is my custom row layout

<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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="wrap_content" android:layout_marginBottom="8dp">

<android.support.v7.widget.CardView
    android:id="@+id/cv_routine_holder"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginEnd="4dp"
    android:layout_marginLeft="4dp"
    android:layout_marginRight="4dp"
    android:layout_marginStart="4dp"
    android:layout_marginTop="4dp"
    app:cardCornerRadius="10dp"
    app:cardBackgroundColor="@color/colorWhite"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/cl_routine_card_holder"
        android:padding="2dp">

        <TextView
            android:id="@+id/tv_routine_course_label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="108dp"
            android:layout_marginLeft="108dp"
            android:layout_marginTop="8dp"
            android:padding="4dp"
            android:text="Course:"
            android:textStyle="bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/tv_routine_course"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:padding="4dp"
            android:text="CSIT"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.05"
            app:layout_constraintStart_toEndOf="@+id/tv_routine_course_label"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/tv_routine_semester_label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="96dp"
            android:layout_marginLeft="96dp"
            android:padding="4dp"
            android:text="Semester:"
            android:textStyle="bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv_routine_course_label" />

        <TextView
            android:id="@+id/tv_routine_semester"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="4dp"
            android:layout_marginLeft="4dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:padding="4dp"
            android:text="5th Sem"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.049"
            app:layout_constraintStart_toEndOf="@+id/tv_routine_semester_label"
            app:layout_constraintTop_toBottomOf="@+id/tv_routine_course" />

        <de.codecrafters.tableview.TableView
            android:id="@+id/tv_routine_table"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="70dp"
            android:background="#dfdfdf"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv_routine_semester_label" />

    </android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>

</android.support.constraint.ConstraintLayout>

ISchwarz23 commented 5 years ago

There is no way to make the table grow depending on it's content. It behaves the same as the ListView in Android. To workaround would be, to set a fixed table height depending on the number of rows.

yubarajoli77 commented 5 years ago

Thanks for your response. Can we scroll the table view inside recyclerView then ? If, yes your help will be appreciated coz recyclerView stops me from scrolling the table. Thanks in advance.

ISchwarz23 commented 5 years ago

Hey, unfortunately the table view cannot change anything about it. You have to make the recycler view forward the scroll events. I don't know how this can be achieved and if this is possible. I also think that the user experience of such a layout will suffer.