SortableTableView icon indicating copy to clipboard operation
SortableTableView copied to clipboard

Problem in showing list of tables in Recyclerview

Open yubarajoli77 opened this issue 5 years ago • 3 comments

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

<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>

yubarajoli77 avatar Dec 06 '18 03:12 yubarajoli77

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.

ISchwarz23 avatar Dec 06 '18 17:12 ISchwarz23

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.

yubarajoli77 avatar Dec 09 '18 07:12 yubarajoli77

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.

ISchwarz23 avatar Dec 09 '18 11:12 ISchwarz23