0

Before I added the RecyclerView to my layout, I was able to click the "TextView" (android:id="@+id/how_is_your_day_question"), which has been programmed to be able to click. After I added the RecylerView to the layout, I am no longer able to click on this TextView. I have played around with the layout and cannot seem to figure it out. Logcat says "I/Surface: opservice is null false" when I click on the TextView. As soon as I remove the RecyclerView, I can click on the TextView item again, and it behaves as expected. I would appreciate any help. Thank you in advance!

UPDATE: I WAS ABLE TO RESOLVE ISSUE AFTER ADDING MARGIN_TOP TO THE RECYCLERVIEW- VERY SILLY MISTAKE. LOL

<androidx.drawerlayout.widget.DrawerLayout
    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"
    android:id="@+id/drawer_layout"
    android:fitsSystemWindows="true"
    tools:context=".Personal_Wall"
    tools:openDrawer="end">






    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">



            <androidx.appcompat.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="#ffff"
            android:id="@+id/toolbar"
            android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            elevation="4dp">



            <ImageView
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:id="@+id/hapana_button"
                android:text="hapana_button"
                android:layout_gravity="right"
                android:paddingRight="10dp"
                android:src="@drawable/ic_hapana_button2"/>


        </androidx.appcompat.widget.Toolbar>


        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:overScrollMode="never"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:fillViewport="true">




        <RelativeLayout
                android:id="@+id/fragment-containter2"
                android:layout_width="match_parent"
                android:layout_height="match_parent">




                <TextView
                android:id="@+id/assists_number"
                android:layout_marginTop="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="46dp"
                android:textSize="12dp"
                android:text="15 Assists *" />

            <TextView
                android:id="@+id/followers_number"
                android:layout_marginTop="10dp"
                android:layout_marginLeft="280dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="12dp"
                android:text="1000 Followers *" />




            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/profile_place_holder"
                android:layout_width="160dp"
                android:layout_height="160dp"
                android:layout_marginTop="120dp"
                android:layout_gravity="center_horizontal"
                android:src="@drawable/profile_place_holder"
                app:civ_border_color="#fff"
                android:elevation="4dp"
                app:civ_border_width="5dp" />

            <androidx.cardview.widget.CardView
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:layout_width="wrap_content"
                android:layout_height="200dp"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="40dp"
                card_view:cardBackgroundColor="#fff"
                card_view:cardCornerRadius="8dp">

            <ImageView
                android:id="@+id/temporary_banner_personal_wall"
                android:layout_width="380dp"
                android:layout_height="200dp"
                android:scaleType="centerCrop"
                android:adjustViewBounds="true"
                android:layout_gravity="center_horizontal"
                app:srcCompat="@drawable/ic_hapana_banner_2"/>
            </androidx.cardview.widget.CardView>




            <TextView
                android:id="@+id/edit_text_first_name"
                android:layout_width="193dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="125dp"
                android:layout_marginRight="50dp"
                android:layout_marginTop="290dp"
                android:layout_weight="0.5"
                android:background="@android:color/transparent"
                android:ems="10"
                android:fontFamily="@font/roboto_medium"
                android:inputType="textPersonName"
                android:text="First"
                android:textColor="#000"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/edit_text_last_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="220dp"
                android:layout_marginTop="290dp"
                android:background="@android:color/transparent"
                android:ems="10"
                android:fontFamily="@font/roboto_medium"
                android:inputType="textPersonName"
                android:text="Last"
                android:textSize="20dp"
                android:layout_weight="0.5"
                android:textColor="#000"/>

            <RatingBar
                android:id="@+id/ratingBar_profile"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="350dp"
                android:layout_gravity="center_horizontal"
                android:scaleX="0.7"
                android:scaleY="0.7"
                android:rating="5"
                android:isIndicator="true"/>

            <View
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:layout_marginTop="540dp"
                android:background="@android:color/darker_gray" />



            <TextView
                android:id="@+id/current_location"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="330dp"
                android:layout_marginLeft="60dp"
                android:textColor="#000"
                android:drawableLeft="@drawable/ic_profile_location_on_black_24dp"
                android:drawablePadding="10dp"
                android:text="Current Location:   City, State" />

            <ImageButton
                android:id="@+id/postsomething"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="460dp"
                android:background="@color/fui_transparent"
                app:srcCompat="@drawable/ic_posting_line"/>




            <TextView
                android:id="@+id/how_is_your_day_question"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="430dp"
                android:layout_marginLeft="25dp"
                android:textSize="18dp"
                android:textColor="#000"
                android:drawablePadding="10dp"
                android:text="How is your day?" />


            <TextView
                android:id="@+id/photo_with_icon_camera"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="480dp"
                android:layout_marginLeft="18dp"
                android:textColor="#000"
                android:drawablePadding="10dp"
                android:drawableLeft="@drawable/ic_profile_camera_grey"
                android:textSize="12dp"
                android:text= "Camera" />

            <TextView
                android:id="@+id/photo_with_icon_video_green"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="480dp"
                android:layout_marginLeft="97dp"
                android:textColor="#000"
                android:drawablePadding="10dp"
                android:drawableLeft="@drawable/ic_profile_video_grey"
                android:textSize="12dp"
                android:text= "Video" />




            <TextView
                android:id="@+id/photo_with_icon_gallery"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="480dp"
                android:layout_marginLeft="173dp"
                android:textColor="#000"
                android:drawablePadding="10dp"
                android:drawableLeft="@drawable/ic_profile_photo_grey"
                android:textSize="12dp"
                android:text= "Photos" />



            <ImageButton
                android:id="@+id/edit_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="280dp"
                android:layout_marginTop="245dp"
                android:background="@color/fui_transparent"
                app:srcCompat="@drawable/ic_edit_icon_2" />






            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/recyclerView_profile_page"
                android:layout_width="match_parent"
                android:layout_height="match_patent"
                android:paddingTop="560dp"
                android:nestedScrollingEnabled="true"
                android:transcriptMode="alwaysScroll"
                android:fillViewport="true"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">

            </androidx.recyclerview.widget.RecyclerView>




        </RelativeLayout>


        </androidx.core.widget.NestedScrollView>


    </LinearLayout>



    <com.google.android.material.navigation.NavigationView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:id="@+id/nav_view"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/drawer_menu"/>



</androidx.drawerlayout.widget.DrawerLayout>

enter image description here

greenTea
  • 29
  • 7

2 Answers2

0

Because your recyclerview's height matches the parent, while all your other views in the same hierarchy as the recycler view have their heights set to wrap content. This would mean that the recycler view is drawing over all its siblings declared above.

I suggest you change android:layout_height="wrap_content" in your RecyclerView and see if it makes any difference.

Rajan Prasad
  • 1,582
  • 1
  • 16
  • 33
  • Thank you for your help. Unfortunately, that solution results in my RecyclerView disappearing when I run the app, and my TextView is still not clickable. – greenTea Mar 21 '20 at 18:29
  • Wait, I will go back to my home and paste it in my Android studio and make it work. – Rajan Prasad Mar 21 '20 at 18:32
0

The problem is being addressed in an earlier answer. The RecyclerView is overlapping the other items and hence they are not clickable.

I would recommend getting rid of the FrameLayout and replace that with a ConstraintLayout or RelativeLayout so that you can position every item without overlapping each other.

The wrap_content is not going to work sometimes if the list is loaded after the RecyclerView is loaded with an empty list first.

Update

After changing it to the RelativeLayout container, looks like it is still covering up all the items that you have in your layout. I would recommend setting the following attribute in your RecyclerView and let me know if that solves your click problem now.

android:layout_below="@+id/how_is_your_day_question"
Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
  • Thank you for your solution. I changed FrameLayout to RelativeLayout, and unfortunately, it results in the TextView still not being clickable. – greenTea Mar 21 '20 at 18:43
  • Can you please share the updated layout that you have? – Reaz Murshed Mar 21 '20 at 18:44
  • Looks like the `RecyclerView` is still overlapping all the items. Do you have a screenshot of the design so that we can understand exactly what you want? – Reaz Murshed Mar 21 '20 at 19:07
  • Also, can you please check my updated answer? Thank you! – Reaz Murshed Mar 21 '20 at 19:10
  • I updated my question with an image. Thank you for your solution. My TextView is now clickable but my RecycleView has disappeared. – greenTea Mar 21 '20 at 19:29
  • Because your `RecyclerView` is still having the `wrap_content`. Please change it to `match_parent` back again. – Reaz Murshed Mar 21 '20 at 19:30
  • IMHO, your layout is way too complicated for this design that you are trying to achieve. Looks like you could have the layout above the `RecyclerView` as a header for the `RecyclerView` and could avoid having the `NestedScrollView`. Here's how you can add a header to your `RecyclerView` just in case - https://stackoverflow.com/a/31154402/3145960 – Reaz Murshed Mar 21 '20 at 19:32
  • 1
    Hi, my apologies. I had the RecyclerView with match_parent, but forgot to update it on stackoverflow. I tried it with match_parent and my RecyclerView stopped appearing. I have updated the code in stackoverflow. I had to add the NestledScrollView because I was experiencing weird scrolling behavior with my RecyclerVew. It wasn't scrolling with the rest of my page so I had to add NestledScrollview. But thank you for the link. I will look at it. – greenTea Mar 21 '20 at 19:40
  • In that case, I would argue that your `RecyclerView` does not have any data :D – Reaz Murshed Mar 21 '20 at 19:41
  • There is data coming in. If I change to FrameLayout, the RecyclerView works with data coming in, but my TextView stops being clickable lol so weird. – greenTea Mar 21 '20 at 19:55