0

I'm doing a to-do list Android app with Kotlin. In my structure todo list items has inner items and you can reach them on editing list fragment. My mainpage has a recyclerview that holds list of the lists. I've added a simple pic I hope it describes it better. And my design needs if you touch anywhere in parent item it redirects you to it's details fragment and it works except if you touch on the inner/child recyclerview. I need to disable the touches of inner recyclerview and if users touch it, and it should act like it's parent and redirects it to the details fragment. Inner/child recyclerview is just a summary, it doesn't needs touches.

[picture of the draft, design will be better after I set things] (https://i.stack.imgur.com/Q8vyO.jpg)

I've tried suppressLayout, layoutFrozen and clickable/focusable for both the child and the parent. I don't know why it doesn't work to be honest.

Edit: Codes added

main fragment xml

    <androidx.constraintlayout.widget.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="match_parent"
tools:context=".ui.main.dashboard.DashboardFragment">

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/rv_lists"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginBottom="4dp"
    android:background="#B1B1B1"
    android:overScrollMode="never"
    app:layout_constraintBottom_toTopOf="@+id/btn_user_settings"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/search_list"
    tools:listitem="@layout/item_to_do_list" /></androidx.constraintlayout.widget.ConstraintLayout>

parent item xml

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:background="#E3E3E3">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_items_preview"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="16dp"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv_list_desc"
        tools:itemCount="2"
        tools:listitem="@layout/item_to_do_item_preview"
        tools:visibility="visible" />

</androidx.constraintlayout.widget.ConstraintLayout>

child item xml

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dp"
    android:background="#E3E3E3">

    <TextView
        android:id="@+id/tv_item_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="4dp"
        android:layout_marginBottom="4dp"
        android:text="@{toDoItem.title}"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toEndOf="@+id/radio_item"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.5"
        tools:text="Item Title" />

    <RadioButton
        android:id="@+id/radio_item"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="4dp"
        android:clickable="false"
        android:minWidth="0dp"
        android:minHeight="0dp"
        android:scaleX="0.8"
        android:scaleY="0.8"
        android:checked="@{toDoItem.completed}"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.5" />

</androidx.constraintlayout.widget.ConstraintLayout>
  • Have you tried wrapping everything in a NestedScrollView and setting clickable / focusable to false ? – ItzDavi Jun 12 '23 at 15:27
  • Maybe create a `FrameLayout`, make it clickable and have it the last thing in the layout (so its on top) – Remc4 Jun 12 '23 at 15:35
  • @Davide I did. I can prevent the touches but I can't make that touches like it touched the parent – Commander Shepard Jun 12 '23 at 15:36
  • Can you share your XMLs ? – ItzDavi Jun 12 '23 at 15:36
  • @Davide adding to question rn. – Commander Shepard Jun 12 '23 at 15:38
  • Oh, you mean there is no ripple effect? – Remc4 Jun 12 '23 at 15:39
  • @Remc4 are you saying wrap inner recyclerview with a layout and set an onclick event? – Commander Shepard Jun 12 '23 at 15:39
  • Ohhh I get it now. That would be a solution, yes. Although any time you're doing a list of lists, you should probably rethink your layout. Maybe you want one list with different item types like here: https://stackoverflow.com/a/26245463/971972 – Remc4 Jun 12 '23 at 15:42
  • How many radio buttons do you expect in each card? If it's like 20 or less, you might be better of without a RecyclerView. That would only be useful if there were so many radio buttons that each card would have to scroll. If there is no scrolling, RecyclerView doesn't do anything useful anyway. – Remc4 Jun 12 '23 at 16:07
  • @Remc4 it depends on the user. Users might don't add anything at all or plenty. It's not mandatory feature, if I couldn't done as like I want I might drop it but still wanted to learn the correct way to fix it. – Commander Shepard Jun 13 '23 at 12:57
  • I still think that the radio buttons should just be in a `LinearLayout`. `RecyclerView` with height set to `wrap_content` behaves in the same way and offers no performance benefits anyway. I think the solution here is to rethink UX (limit the user to max 50 radio buttons), or show only the first 20 items and when the user clicks on the card, the full list of options shows up. – Remc4 Jun 13 '23 at 14:57
  • 1
    @Remc4 So you suggest instead of recyclerview I should add a layout and add radio buttons programmatically like adding them in a foreach loop. Sounds logical I'll try that – Commander Shepard Jun 14 '23 at 11:27

0 Answers0